The manual outlines command line options here: Unity - Manual: Command line arguments but there is no mention of building a WebGL project. Has anyone found a flag to do such with the Unity 5 Beta?
Unity 5.0.1 has BuildTarget.WebGL
//place this script in the Editor folder within Assets.
using UnityEditor;
//to be used on the command line:
//$ Unity -quit -batchmode -executeMethod WebGLBuilder.build
class WebGLBuilder {
static void build() {
string[] scenes = {"Assets/main.unity"};
BuildPipeline.BuildPlayer(scenes, "WebGL-Dist", BuildTarget.WebGL, BuildOptions.None);
}
}
(from Unity command line script to build WebGL player · GitHub)
There’s not a flag for this yet.
Here is a Programmer to English translation of the answers in this thread:
There is currently no command line argument to build a WebGL player. To work around this, you can use the command line argument to run a c# script. You can create a c# script that makes calls to Unity to do the building, and then run that script from the command line.
Here is the script to make. It goes in the Assets/Editor folder of your project.
using UnityEditor;
class WebGLBuilder {
static void build() {
string[] scenes = {"Assets/main.unity"};
BuildPipeline.BuildPlayer(scenes, "WebGL-Dist", BuildTarget.WebGL, BuildOptions.None);
}
}
Then use the command line option to call the code in the c# script:
Unity.exe -quit -batchmode -executeMethod WebGLBuilder.build
Specifically, note the -executeMethod command line argument, which lets you call a method in a c# class in the project.