Setting custom webgl tags through script

Hi all!

Is it possible to set a custom webgl tag through script? I can’t find anything on it?
I have a Version tag that I would like to set when making a new build.

Is this possible at all?

Cheers,
Pieter

Hi,
What’s a webgl tag?

Hi!

Sorry for being so unclear - I just reread my first post and I can understand any confusion.

What I mean with webgl tag is a custom template tag which you can set and use in a webgl template (html)

So atm I have a UNITY_CUSTOM_TAG_VERSION. This shows up as an editable textfield in the player settings inspector.

I would like to set this dynamically (each time I make a new build).

Is this possible?

Thanks,
Pieter

I’d have the exact same question here. Any findings?

You can do this via via PostProcess scripts that get called after you build is finished. See Unity - Manual: Build Player Pipeline

How? I don’t see that Unity has any API for setting values for custom tags in WebGL Templates.

I think this is all the API we get access to as far as WebGL Player Settings go: https://docs.unity3d.com/ScriptReference/PlayerSettings.WebGL.html

That does not include custom tags unfortunately.

Template Tags are described in here:
https://docs.unity3d.com/Manual/webgl-templates.html

1 Like

Hi! Have you found a solution of your problem? (Sorry for my english)

I use parse index.html file and replace custom tags with my own values

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
7 Likes