Unity/Editor/プレイヤービルド
提供: 初心者エンジニアの簡易メモ
Assets/Editor/BuildPlayerExample.cs
using UnityEditor; using UnityEngine; using UnityEditor.Build.Reporting; public class BuildPlayerExample : MonoBehaviour { [MenuItem("Build/Build WebGL")] public static void MyBuild() { BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions(); buildPlayerOptions.scenes = new[] { "Assets/Scenes/SampleScene.unity" }; buildPlayerOptions.locationPathName = "WebGLBuild"; // 生成されるビルドのディレクトリ名 buildPlayerOptions.target = BuildTarget.WebGL; 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"); } } }
BuildPipelineの公式マニュアル:http://docs.unity3d.com/ja/current/ScriptReference/BuildPipeline.BuildPlayer.html