Action disabled: source

플레이어 파이프라인의 구축(Build Player Pipeline

플레이어를 구축할 때, 사용자는 어떤 방식으로 구축된 플레이어를 변경하고 싶을 경우가 있습니다. 예를 들면, 사용자 정의 아이콘을 추가하거나, 플레이어 옆에 어떤 문서를 복사하거나, 혹은 설치 프로그램을 빌드 하고자 할 수 있습니다. 이러한 작업을 수동으로 하는 것은 힘들 수 있으며, 만일 사용자가 sh나 perl 스크립트를 작성하는 방법을 알고 있다면 이러한 작업을 자동화 할 수 있습니다.

Mac OSX

플레이어를 빌드하면, Unity는 사용자 프로젝트의 Assets/Editor 폴더에서 자동적으로 _PostprocessBuildPlayer_ (확장자 없이)라는 sh 혹은 perl 스크립트를 검색한다. 이 파일을 찾으면, 플레이어가 구축을 끝낼 때 이를 구동 시킵니다.

이 스크립트에서, 사용자는 원하는 어떠한 방식이건 해당 플레이어를 후처리 할 수 있습니다. 예를 들면, 플레이어에서 설치프로그램을 구축할 수 있습니다.

사용자는 perl, sh 혹은 명령라인에 호환되는 다른 어떤 언어를 사용할 수 있습니다.

Unity는 스크립트에 필요한 명령 라인 인수를 전달하여, 사용자는 그것이 어떠한 종류의 플레이어 이며 어디에 저장되었는지 알 수 있게 됩니다.

현재 디렉터리는 프로젝트 폴더, 즉 Assets 폴더를 포함하는 폴더로 설정될 것입니다.

#!/usr/bin/perl
 
my $installPath = $ARGV[0];
 
  - The type of player built:
  - "dashboard", "standaloneWin32", "standaloneOSXIntel", "standaloneOSXPPC", "standaloneOSXUniversal", "webplayer"
my $target = $ARGV[1];
 
  - What optimizations are applied. At the moment either "" or "strip" when Strip debug symbols is selected.
my $optimization = $ARGV[2];
 
  - The name of the company set in the project settings
my $companyName = $ARGV[3];
 
  - The name of the product set in the project settings
my $productName = $ARGV[4];
 
  - The default screen width of the player.
my $width = $ARGV[5];
 
  - The default screen height of the player 
my $height = $ARGV[6];
 
print ("n*** Building at '$installPath' with target: $target n");

주의할 것은, Python과 같은 일부 언어에서는, 명령 라인 인수의 하나로 스크립트의 이름을 전달합니다. 만일 사용자가 이 중 한 언어를 사용한다면, 그 인수는 효과적으로 배열에서 한 자리를 이동할 것입니다 (그러므로 설치 경로는 ARGV[1]이 되는 것, 등입니다).

이 기능이 작동하는 것을 보려면, 당사 웹 사이트의 Example Projects 페이지를 방문하여 PostprocessBuildPlayer 예제 패키지 파일을 다운 받아 이를 사용자 자신의 프로젝트에서 사용을 위해 들여오기를 수행합니다. 이는 플레이어 파이프라인 구축(Build Player Pipeline) 기능을 사용하여, 사용자가 자신의 PostprocessBuildPlayer 스크립트에 구현할 수 있는 사용자 설정 구축 작업의 종류를 보여주기 위하여 웹 플레이어 빌드의 사용자 지정한 후처리(customized post-processing) 기능을 제공합니다.

Windows

Windows에서는, PostprocessBuildPlayer 스크립트를 지원하지 않는다. 그러나 사용자는 편집기 스크립팅을 사용하여 같은 결과를 얻을 수 있습니다. BuildPipeline.BuildPlayer 을 사용하여 해당 빌드를 수행하고, 그리고 사용자가 필요한 후처리 코드를 덧붙일 수 있습니다:-

using UnityEditor;
using System.Diagnostics;
 
public class ScriptBatch : MonoBehaviour 
{
    [MenuItem("MyTools/Windows Build With Postprocess")]
    public static void BuildGame ()
    {
        // Get filename.
        string path = EditorUtility.SaveFolderPanel("Choose Location of Built Game", "", "");
 
        // 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/WebPlayerTemplates/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();
    }
}

역링크