Version: 2017.3
고급 에디터 토픽
커맨드 라인 인자(Command line arguments)

플레이어 빌드 파이프라인

플레이어를 빌드할 때 빌드된 플레이어를 수정하고 싶을 때가 있습니다. 예를 들어 커스텀 아이콘을 추가하거나, 몇 개의 문서를 플레이어 옆에 복사하거나 설치 프로그램을 빌드하고 싶을 수 있습니다. 이 작업은 에디터 스크립트를 통해 BuildPipeline.BuildPlayer를 사용하여 빌드를 실행한 후 필요한 포스트 프로세싱 코드를 뒤에 붙여서 수행할 수 있습니다.

// JS example.

import System.Diagnostics;

class ScriptBatch {
    @MenuItem("MyTools/Windows Build With Postprocess")
    static function BuildGame() {
        // Get filename.
        var path = EditorUtility.SaveFolderPanel("Choose Location of Built Game", "", "");
        var levels : String[] = ["Assets/Scene1.unity", "Assets/Scene2.unity"];
        
        // Build player.
        BuildPipeline.BuildPlayer(levels, path + "/BuiltGame.exe", BuildTarget.StandaloneWindows, BuildOptions.None);

        // Copy a file from the project folder to the build folder, alongside the built game.
        FileUtil.CopyFileOrDirectory("Assets/Templates/Readme.txt", path + "Readme.txt");

        // Run the game (Process class from System.Diagnostics).
        var proc = new Process();
        proc.StartInfo.FileName = path + "/BuiltGame.exe";
        proc.Start();
    }
}
// C# example.
using UnityEditor;
using System.Diagnostics;

public class ScriptBatch 
{
    [MenuItem("MyTools/Windows Build With Postprocess")]
    public static void BuildGame ()
    {
        // Get filename.
        string path = EditorUtility.SaveFolderPanel("Choose Location of Built Game", "", "");
        string[] levels = new string[] {"Assets/Scene1.unity", "Assets/Scene2.unity"};

        // Build player.
        BuildPipeline.BuildPlayer(levels, path + "/BuiltGame.exe", BuildTarget.StandaloneWindows, BuildOptions.None);

        // Copy a file from the project folder to the build folder, alongside the built game.
        FileUtil.CopyFileOrDirectory("Assets/Templates/Readme.txt", path + "Readme.txt");

        // Run the game (Process class from System.Diagnostics).
        Process proc = new Process();
        proc.StartInfo.FileName = path + "/BuiltGame.exe";
        proc.Start();
    }
}

PostProcessBuild 속성

PostProcessBuildAttribute의 postprocessOrder 파라미터를 사용하여 빌드 메서드 실행 순서를 결정하고 이전 섹션에서 봤던 것처럼 이 메서드의 Process 클래스를 사용하여 외부 스크립트를 호출할 수 있습니다. 이 파라미터는 빌드 메서드를 오름차순으로 정렬하는 데 사용되고, 파라미터에 임의의 음수나 양수 값을 할당할 수 있습니다.

고급 에디터 토픽
커맨드 라인 인자(Command line arguments)
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961