Hello Unity dev,
I was trying to use your PlayerSettings.WebGL.template and to do so, I basically just read the documentation from your website :
This documentation seems pretty clear by the way : Path to the WebGL template asset.
So to patch this part during my automation process, I just read the WebGLTemplates folder and set this variable with the one I need.
When I execute my straightforward code based on your documentation, my build failed with this message
IndexOutOfRangeException: Index was outside the bounds of the array.
UnityEditor.WebGL.WebGlBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at /Users/builduser/buildslave/unity/build/PlatformDependent/WebGL/Extensions/Unity.WebGL.extensions/BuildPostprocessor.cs:936)
UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at C:/buildslave/unity/build/Editor/Mono/Modules/DefaultBuildPostprocessor.cs:27)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:286)
UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)
ChangeTemplateBuild:ChangeTemplateOnBuild() (at Assets/Scripts/Editor/ChangeTemplateBuild.cs:20)
this message was odd to me. Why I obtained a index out of range ? In the documentation you only mentionned a string. I was sceptical.
Then I debug the value you currently save in it and the result just blow my mind…
When it’s your template it’s
APPLICATION:UnityTemplateName
and when it’s user based template it’s
PROJECT:UserTemplateName
So just please I have 3 requests :
1. Could you update your documentation and change this “path” notion cause it’s wrong. You can’t call it a “path”.
2. Could you change your error message and just say syntax is incorrect instead of do all your process and fail. Maybe using a try catch or something like this could be a nice idea ?
3. When it failed, Unity will select the first user custom template in the list which is quite odd too. When you have only one template, your user can think : Why does it fail because it selects the good one ?
Thanks.