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