Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Official WebGL Custom Template Support

Discussion in 'Unity Build Automation' started by branwenevans, Apr 28, 2023.

  1. branwenevans


    Unity Technologies

    Mar 28, 2017
    WebGL Custom Template Support

    We’re happy to share that Unity Build Automation now supports using custom templates for WebGL builds, and UBA will no longer force WebGL builds to build with the default template. We know this is something you might have been wanting for a long time, and we’re glad it’s finally here.

    Currently WebGL target builds (using either default or custom templates) are only supported on the Mac Builder operating system (OS). Later this year we plan to enable support for WebGL on Windows OS Builders - we’ll share more on that later in the year.

    Configuring a custom template for your WebGL build is handled entirely in your Unity project, please refer to the Unity Manual for details on how to set this up:

    Once you’ve updated your project to use a custom template - and ensured that your project builds locally - make sure that your changes are checked into source control, and you should be ready to build your custom template WebGL build with UBA.

    Playing WebGL Builds from the Dashboard

    If you already use UBA to build for WebGL, you’re likely aware that the UBA dashboard gives you the ability to play your WebGL build within the dashboard, for testing purposes.

    With the introduction of custom templates, we can’t guarantee that your build will play or display properly when played in the dashboard - we won’t stop you from trying to play your build in the dashboard if you’re using a custom template, but we won’t be able to support you if it doesn’t work as you expect.

    Playing WebGL builds using the default template will continue to function as before.
  2. legoesbenr


    Apr 27, 2022
    As far as I can see, it's still not possible to configure a custom template in the Unity Cloud Build configuration. This means that we have to configure it in the repo.
    This results in not being able to run one template on local machines and another template in the build cloud.
    It should be possible to specify the template in the cloud build configuration.

    Are there any progress with this?
  3. Shredsauce


    Apr 4, 2016
    Very good move. I'm glad this is finally possible.

    You could do something like this in OnPreprocessBuild:

    Code (CSharp):
    2.     PlayerSettings.WebGL.template = "PROJECT:CloudBuildWebGLTemplate";
    3. #else
    4.     PlayerSettings.WebGL.template = "PROJECT:LocalWebGLTemplate";
    5. #endif
  4. branwenevans


    Unity Technologies

    Mar 28, 2017
    That's correct, you do have to configure the template in your repo. At the moment we aren't planning to add anything to the UBA config to allow specifying a different template to what is used locally, but @Shredsauce's suggestion should work well if that's something you want to try.
  5. Matheuz


    Aug 27, 2014
    That's great news. It took a while, but I'm glad this has finally been implemented.