Git Product home page Git Product logo

better-unity-webgl-template's Introduction

A Better Unity WebGL template

I have no idea why Unity choose to not make its WebGL exporter default to filling the window like pretty much all other WebGL apps on the net but in any case here is a template

screenshot

Example: https://greggman.github.io/better-unity-webgl-template/

Instructions 2020

Download and add in this unity package into your project. Then pick Edit->Project Settings->Player, in the WebGL tab under Resolution and Presentation pick "Better2020".

Change Assets/WebGLTemplates/Better2020/logo.png to whatever you want.

You can also set "Hide Full Screen Button" to 1 or true if you don't want the fullscreen button to appear in the bottom right.

See Unity docs on how to customize WebGL Templates.

Instructions 2019

Download and add in this unity package into your project. Then pick Edit->Project Settings->Player, in the WebGL tab under Resolution and Presentation pick "BetterTemplate".

Change Assets/WebGLTemplates/BetterTemplate/logo.png to whatever you want.

See Unity docs on how to customize WebGL Templates.

Changelist

  • 0.1.0

    • Add Unity 2020
  • 0.0.3

    • Try to make mobile dialog appear above logo.

      It's a little sad that Unity hard coded this rather than make it some kind of event and/or make the template itself handle this. The issue is there's no easy way to know if the inserted elements are the mobile warning or something else.

      I suppose could check if the game has actually loaded. If no it's the mobile warning. If yes then disable the CSS. Oh well, burn that bridge when we get there.

    • Fix logo size css

    • Add viewport tag

better-unity-webgl-template's People

Contributors

greggman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

better-unity-webgl-template's Issues

Do you support percentage loading progress ?

Hi Team,

I really like this simple and pretty template. Could you support percentage for the loading bar ?

I think it would be the best free template if have loading percentage progress.

Hope to hear from you soon ?

Thank you for your sharing.
Duc Hoang

How to set a maximum size limit?

I want my game to be responsive if browser window is smaller than a specific size (960 px width). But stay the same size if window is larger. How do I go about doing that?

Web cam permission

No web cam permission, building with a default template it asks for, now it crashes

2021.2 Main Scene Doesnt Load

First, thank you and great job on the loader.

Im using 2021.2. The loading screen appears, but just hangs there forever. Is there a method that needs to bee called in order to get the main scene to load after the WebGL loader has completed d/loading?

After further looking into it, when im using a new template... the build doesn't generate the folder "TemplateData".

OnRectTransformDimensionsChanged doesn't get called when resizing browser

This is probably a more general Unity issue but I don't seem to be getting OnRectTransformDimensionsChanged calls when resizing the browser window. I'll be digging into this more today but I suspect the issue could be solved with some clever javascript.

I'll make sure to post any info I find.

Full screen on click

The game goes full screen when I first click on the canvas.

For now I stopped this behaviour by adding a Fullscreen.jslib to the project with this code:

var LibraryFullscreen = {
    JS_SystemInfo_HasFullscreen: function()
    {
        return 0;
    }
};
mergeInto(LibraryManager.library, LibraryFullscreen);

I'm on the latest version of Chrome, if it matters (looks like it doesn't happen on Firefox).
Thanks for the help :)

Compilation error on Unity 2020.1.8f1

Hi,

Building for WebGL with the better template 2020 does not compile. The error is that HIDE_FULL_SCREEN_BUTTON is not defined.

Thanks for a very cool template!

Hey! Template works on LocalHost when build and run, but does not work when uploading game on server

Hey ! This really works on localHost, but when I upload the project on server, the project crashes, just small black squire appears and this is error message:
.loader.js:1 wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.

Also I tried to add this in blank project, it works but when I import my game package, still does not works..
Any ideas? big thanks anyway for this asset!

How to import package to 2019?

Hi this is probably a stupid question, but I can't see a way to import this to 2019.

In 2020 the package manager recognizes it, but in 2019 it doesn't recognise the zip, the contents of the zip, or the file without the zip extension as a package.

Just copying the template from the source code into assets worked when I hit build and run, but then trying to serve it from my own server (either locally or remote) didn't work.

Sorry if I'm being stupid!

Flicker when Resize?

When I resize the window, I get really bad flickering of the canvas from black then back to normal.
Has anyone else encountered this?

Thanks!

Timeout = 2000?

Curious what the purpose of the 2000 (2 sec) timeout before the loading screen disappears? is there a reason for that? It doesn't seem to be in the original unity webgl template so not quite sure if it serves an actual purpose in your template?

setTimeout(function() {
loader.style.display = "none";
}, 2000);

Basically it adds a blanket 2 seconds to the game loading, and we're trying to shave off seconds wherever we can, so want to make sure we're safe to remove this.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.