Skip to content

Instantly share code, notes, and snippets.

@iegik
Created November 8, 2023 11:55
Show Gist options
  • Save iegik/e8a7fae3b1a96018b4fbb7bec3fe63ff to your computer and use it in GitHub Desktop.
Save iegik/e8a7fae3b1a96018b4fbb7bec3fe63ff to your computer and use it in GitHub Desktop.

Build

using UnityEditor;
using UnityEngine;

public class Build
{
    static void WebGLProductionBuild()
    {
        // Build the player.\
        BuildPlayerOptions buildPlayerOptions =  new BuildPlayerOptions();
        buildPlayerOptions.scenes = new[] { "Assets/Scenes/SampleScene.unity" };
        buildPlayerOptions.locationPathName = "Build";
        buildPlayerOptions.target = BuildTarget.WebGL;
        buildPlayerOptions.options = BuildOptions.None; // set whatever you want here
        BuildPipeline.BuildPlayer(buildPlayerOptions);  // apply the setting changes
        Debug.Log("BuildPlayerOptions\n"
            + "Scenes: " + string.Join(",", buildPlayerOptions.scenes) + "\n"
            + "Build location: " + buildPlayerOptions.locationPathName + "\n"
            + "Options: " + buildPlayerOptions.options + "\n"
            + "Target: " + buildPlayerOptions.target);
    }
}
/Applications/Unity/Hub/Editor/2021.3.28f1/Unity.app/Contents/MacOS/Unity -quit -projectPath . -batchmode -executeMethod Build.WebGLProductionBuild -logFile build.log -nographics & tail -f build.log
Unity.exe -quit -projectPath . -batchmode -executeMethod Build.WebGLProductionBuild -logFile build.log -nographics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment