Comments

Log in with itch.io to leave a comment.

Viewing most recent comments 2 to 7 of 103 · Next page · Last page

For anyone following this with a recent version of Unity (e.g. the 2023.x and 6.x branches), note that there is no longer a "WebGL" platform, but just "Web" instead.

Also the menu structure has changed. After switching to the "Web" platform, o apply the template you now need to go to: 

Edit -> Project Settings -> Player, and select "BetterMinimal" template under the Resolution and Presentation heading.

(1 edit)

Thanks

Hey, trying to use this, but sadly the template won't appear as an option in unity. I just see the default options. 

Check to make sure you're putting the extracted folder (i.e. the "WebGLTemplates" folder, not the "BetterMinimal" folder inside it or the zip itself) inside your "Assets" folder.

Hey Sean - That was it!
 I did a number of silly things to break it in the middle of the night. I first dragged the "BetterMinimal" folder only. Then I realized I needed the "WebGLTemplates" folder, so I drag and dropped that, but since I'd already dragged in the "BetterMinimal" folder, the "WebGLTemplates" folder was empty. 

Once I had it set up correctly, I had to quit and reopen Unity for it to work. 

Anyway, thanks for listening - this tool was perfect for my needs! 

(tangent: I'm wondering if I can somehow make the game resize to be within the horizontal space on itch.io. With my default resolution (full HD) it was so big that the game wasn't fully in view, creating horizontal and vertical scrollbars. I changed the viewport on itch to force it to half that resolution and now it's good, but it'd be cool for that resize to occur automatically)

I believe making the size of the itch viewport reponsive is only possible if you have custom CSS enabled on your account (in which case you can write custom CSS that uses percentage, viewport units, or breakpoints instead of the fixed size from your game's embed settings).

(+3)

i had an issue of the loading bar appearing for no reason when entering full screen. i added "window.focus();" to the end of onResize() which fixes it. maybe could be considered to be added to the asset :)

Having the same issue here, thanks for solution!

(3 edits) (+2)

Awesome stuff!
Also, i would consider adding this (new?) feature for saving PlayerPrefs and files:

Add "autoSyncPersistentDataPath: true" to the config={}
https://docs.unity3d.com/Manual/web-templates-build-configuration.html

Also, adding '-webkit-user-select: none; user-select: none;' to 'div#gameContainer canvas' is advised https://discussions.unity.com/t/odd-issue-with-focus-in-firefox/1651226/2 

(+2)

Thanks for the suggestions, this does seem like a better default. I've added it to the "2020.2 and higher" version.

(1 edit)

Found another issue which i asked ChatGPT about with this prompt:

"I got a webgl unity build with a loading bar. It works the first time, but when I update my build and the cache needs to refresh the loading bar stays at 100% throughout the new download"

and it gave me this suggestion, can you make sense of it and if it is worth of an update if you can reproduce:

<script>

  const buildUrl = "Build";

  const loaderUrl = buildUrl + "/yourproject.loader.js";

  const config = {

    dataUrl: buildUrl + "/yourproject.data",

    frameworkUrl: buildUrl + "/yourproject.framework.js",

    codeUrl: buildUrl + "/yourproject.wasm",

    streamingAssetsUrl: "StreamingAssets",

    companyName: "YourCompany",

    productName: "YourProduct",

    productVersion: "1.0",

  };

  const loadingBar = document.getElementById("loadingBar");

  const progressBarFull = document.getElementById("progressBarFull");

  const updateProgress = (progress) => {

    progressBarFull.style.width = `${100 * progress}%`;

  };

  const script = document.createElement("script");

  script.src = loaderUrl;

  script.onload = () => {

    createUnityInstance(document.querySelector("#unity-canvas"), config, (progress) => {

      updateProgress(progress);

    }).then((unityInstance) => {

      loadingBar.style.display = "none";

    }).catch((message) => {

      alert(message);

    });

  };

  document.body.appendChild(script);

</script>

Key Points:

  • The progress callback inside createUnityInstance() doesn’t always track actual download progress after cache updates unless you handle it explicitly.

  • The Unity loader might say "100%" because it thinks it's loading from cache, but the browser is still re-downloading the new files.

__________

Apart from that, i am also checking out renderResolution control in WebGL for improving performance. That would also be a worthy addition

Thank you so much for this tool. I'm wondering if there is a way to remove the black/custom bars when resizing it; for the game view to take up the entire screen in fullscreen mode.

ah i think i've solved it, for anyone else wondering: comment out these. thanks again for the great template :)

// if (w * r > window.innerHeight) {

//  w = Math.min(w, Math.ceil(h / r));

// }

//h = Math.floor(w * r);

Viewing most recent comments 2 to 7 of 103 · Next page · Last page