Search Unity

Official WebGL Custom Template Support

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

  1. branwenevans

    branwenevans

    Unity Technologies

    Joined:
    Mar 28, 2017
    Posts:
    7
    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: https://docs.unity3d.com/Manual/webgl-templates.html

    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

    legoesbenr

    Joined:
    Apr 27, 2022
    Posts:
    10
    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

    Shredsauce

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

    You could do something like this in OnPreprocessBuild:

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

    branwenevans

    Unity Technologies

    Joined:
    Mar 28, 2017
    Posts:
    7
    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

    Matheuz

    Joined:
    Aug 27, 2014
    Posts:
    30
    That's great news. It took a while, but I'm glad this has finally been implemented.
     
  6. JaelynAvery

    JaelynAvery

    Joined:
    Oct 5, 2023
    Posts:
    1
    For those of you who are interested in setting up custom templates, the Unity Manual provides a comprehensive guide on how to do it. You can find step-by-step instructions on creating and implementing your own templates for WebGL builds. Once you've made your changes and successfully built your project locally, don't forget to commit your changes to source control to keep everything organized. By the way, I've some nice calendar templates that may be helpful for you guys. You can check out this link: https://docsandslides.com/googledocs/calendar/. They have a variety of calendar templates that you can use for your Google Docs.
     
    Last edited: Oct 9, 2023