Version: 5.5
고급 에디터 토픽
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