Question by
godszerg86 · Jan 30, 2019 at 03:39 PM ·
script.webglbuilding
WebGl build from command line doesn't work.
I have a WebGL project. It builds and works when I build it from Editor in a regular way: File -> Build Settings or Build and Run it works But when I build it with the script it doesn't. I have a strong feeling that I missing some settings or options in my code. Because "regular way build" is 100mb, but code build is only 13mb.
Here is my build code
var buildPlayerOptions = new BuildPlayerOptions();
buildPlayerOptions.scenes = new[] { "Assets/Scenes/SampleScene.unity" };
buildPlayerOptions.locationPathName = "WEBGL";
buildPlayerOptions.target = BuildTarget.WebGL;
buildPlayerOptions.options = BuildOptions.None;
PlayerSettings.WebGL.analyzeBuildSize = false;
PlayerSettings.WebGL.memorySize = 256;
PlayerSettings.WebGL.dataCaching = true;
PlayerSettings.WebGL.compressionFormat = WebGLCompressionFormat.Gzip;
PlayerSettings.runInBackground = true;
PlayerSettings.defaultScreenHeight = 480;
PlayerSettings.defaultScreenWidth = 640;
PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Both;
PlayerSettings.WebGL.debugSymbols = true;
PlayerSettings.WebGL.exceptionSupport = WebGLExceptionSupport.FullWithStacktrace;
var buildReport = BuildPipeline.BuildPlayer(buildPlayerOptions);
if (buildReport.summary.result == BuildResult.Succeeded)
{
EditorApplication.Exit(0);
}
else
{
EditorApplication.Exit(1);
}
Comment
Hello, did you manage to resolve this? I'm facing the same issue, where the size from the command line is smaller than from the editor, and the command line build is missing models.
Answer by Marco-Trivellato · Feb 21, 2019 at 06:24 PM
I suspect what you want is a non-development build. Try to add:
EditorUserBuildSettings.development = false;
and maybe change linkerTarget to only output WebAssembly:
PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Wasm;
Your answer
![](https://koobas.hobune.stream/wayback/20220612190756im_/https://answers.unity.com/themes/thub/images/avi.jpg)