facebook twitter hatena line email

「Unity/Editor/プレイヤービルド」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(ページの作成:「Assets/Editor/BuildPlayerExample.cs <pre> using UnityEditor; using UnityEngine; using UnityEditor.Build.Reporting; public class BuildPlayerExample : MonoBehaviour { [...」)
 
行10: 行10:
 
     {
 
     {
 
         BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
 
         BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
         buildPlayerOptions.scenes = new[] { "Assets/Scenes/SampleScene.unity"/*, "Assets/Scene2.unity" */};
+
         buildPlayerOptions.scenes = new[] { "Assets/Scenes/SampleScene.unity" };
         buildPlayerOptions.locationPathName = "WebGLBuild";
+
         buildPlayerOptions.locationPathName = "WebGLBuild"; // 生成されるビルドのディレクトリ名
 
         buildPlayerOptions.target = BuildTarget.WebGL;
 
         buildPlayerOptions.target = BuildTarget.WebGL;
 
         buildPlayerOptions.options = BuildOptions.None;
 
         buildPlayerOptions.options = BuildOptions.None;

2021年8月3日 (火) 17:54時点における版

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");
        }
    }
}