Version: 2022.2
言語: 日本語
public static Build.Reporting.BuildReport BuildPlayer (BuildPlayerOptions buildPlayerOptions);

パラメーター

buildPlayerOptions Provide various options to control the behavior of BuildPipeline.BuildPlayer.

戻り値

BuildReport A BuildReport giving build process information.

説明

プレイヤーをビルドします。

プログラムから Unity プロジェクトをビルドするにはこの関数を使用します。

Calling this method will invalidate any variables in the editor script that reference GameObjects, so they will need to be reacquired after the call.

Scripts can run at strategic points during the build by implementing one of the supported callback interfaces, for example BuildPlayerProcessor, IPreprocessBuildWithReport, IProcessSceneWithReport and IPostprocessBuildWithReport.

Note: Be aware that changes to scripting symbols only take effect at the next domain reload, when scripts are recompiled.

This means if you make changes to the defined scripting symbols via code using PlayerSettings.SetDefineSymbolsForGroup without a domain reload before calling this function, those changes won't take effect.

It also means that the built-in scripting symbols defined for the current active target platform (such as UNITY_STANDALONE_WIN, or UNITY_ANDROID) remain in place even if you try to build for a different target platform, which can result in the wrong code being compiled into your build.

See Also: BuildPlayerWindow.DefaultBuildMethods.BuildPlayer.

using UnityEditor;
using UnityEngine;
using UnityEditor.Build.Reporting;

// Output the build size or a failure depending on BuildPlayer.

public class BuildPlayerExample { [MenuItem("Build/Build iOS")] public static void MyBuild() { BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions(); buildPlayerOptions.scenes = new[] { "Assets/Scene1.unity", "Assets/Scene2.unity" }; buildPlayerOptions.locationPathName = "iOSBuild"; buildPlayerOptions.target = BuildTarget.iOS; buildPlayerOptions.options = BuildOptions.None;

BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions); BuildSummary summary = report.summary;

if (summary.result == BuildResult.Succeeded) { Debug.Log("Build succeeded: " + summary.totalSize + " bytes"); }

if (summary.result == BuildResult.Failed) { Debug.Log("Build failed"); } } }

public static Build.Reporting.BuildReport BuildPlayer (string[] levels, string locationPathName, BuildTarget target, BuildOptions options);
public static Build.Reporting.BuildReport BuildPlayer (EditorBuildSettingsScene[] levels, string locationPathName, BuildTarget target, BuildOptions options);

パラメーター

scenes The Scenes to include in the build. If empty, the build only includes the currently open Scene. Paths are relative to the project folder (Assets/MyLevels/MyScene.unity).
locationPathName 成果物の保存先のパス
target ビルドする BuildTarget
options ビルドしたプレイヤーを実行するか、などの追加の BuildOptions

戻り値

BuildReport エラーが発生した場合、エラーメッセージを返します。

説明

Builds a player. These overloads are still supported, but will be replaced. Please use BuildPlayer (BuildPlayerOptions buildPlayerOptions) instead.