public static Build.Reporting.BuildReport BuildPlayer (BuildPlayerOptions buildPlayerOptions);

파라미터

buildPlayerOptionsProvide various options to control the behavior of BuildPipeline.BuildPlayer.

반환

BuildReport A BuildReport giving build process information.

설명

Builds a player.

Use this function to programatically create a build of your project. Note that any references to GameObjects acquired in the editor script before the BuildPlayer call will be invalid after it and will need to be reacquired.

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

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

public class BuildPlayerExample : MonoBehaviour { [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);

파라미터

levelsThe scenes to be included in the build. If empty, the currently open scene will be built. Paths are relative to the project folder (Assets/MyLevels/MyScene.unity).
locationPathNameThe path where the application will be built.
targetThe BuildTarget to build.
optionsAdditional BuildOptions, like whether to run the built player.

반환

BuildReport An error message if an error occurred.

설명

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

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961