Hey y’all, I’m currently working on a build tool that automatically creates multiple WebGL builds with different player settings. I’m doing this in 2020.1 and I know that 2020.1 introduced the ability to use custom javascript macros in WebGL templates. Is it possible to modify the values of these macros from script (like a C# build script or something) or elsewhere? I’m asking because it would be cumbersome to have to change them manually in the player settings.
1 Like
You can modify player settings variables, indeed everything you could typically modify in the Editor, from an Editor script. Try using Rider and poking about the assemblies to find the methods you need.
Sorry for necroposting, but I haven’t found an answer to this in any of the threads, so decided to share the solution after some digging.
To set it from script you should use PlayerSettings.SetTemplateCustomValue()
method, which is for some reason not in the PlayerSettings.WebGL
group (which is why it may be hard to find).
- Note that the docs now call it Custom user variables, they don’t require
UNITY_CUSTOM_
prefix anymore, and are using{{{ triple brackets }}}
instead of%percentage%
wrappers - They are also quite buggy to update, either not appearing in the settings or clearing up after input - restarting Unity and running a build fixed that for me
- Doing this on 2021.3
3 Likes