unity only has a fixed resolution for building webgl. how can I make it changebale on users browser size change.

there are some tutorials on the internet that doesn't match. there is only

index.html unityloader.js gamename.json gamename.data.unityweb gamename.asm.memory.unityweb gamename.framework.unityweb gamename.asm.code.unityweb

how can I make multi res webgl output happen for unity?


1 Answer 1


change the HTML as documented here. You can choose either one of the defaults or create your own template.

According to those docs you create folder in Assets called WebGLTemplates and inside that create a new folder for your template like BetterTemplate. Inside that put an index.html file and any other images, css, JavaScript files you want included with your game.

The index.html could look something like this

<!DOCTYPE html>
<html lang="en-us">

    <meta charset="utf-8">
      body { margin: 0; }
      #gameContainer { width: 100vw; height: 100vh; }
      canvas { width: 100%; height: 100%; }
    <script src="Build/UnityLoader.js"></script>
    var gameInstance = UnityLoader.instantiate("gameContainer", "Build/dist.json");

    <div id="gameContainer"></div>


Then you pick Edit->Project Settings->Player from the menus and under the WebGL tab choose your template

Here's an example.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .