Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UnityLoader.js

Discussion in 'Web' started by srmatthe, May 15, 2016.

  1. srmatthe

    srmatthe

    Joined:
    May 15, 2016
    Posts:
    11
    Anyone know if the UnityLoader.js file is available non-minified as a template so that is can be customised and included in the build each time ?

    There's a few bits i'd like to change to make it more usable for our project but have it built as part of the process rather than needing to manually change it afterwards. Things like localising the language for the error messages and such so not affecting the core loading scripts.
     
  2. pchuri

    pchuri

    Joined:
    Aug 18, 2014
    Posts:
    12
  3. srmatthe

    srmatthe

    Joined:
    May 15, 2016
    Posts:
    11
    It's not the template that I need to work with. I embed it in to our website already.

    The problem is with the minified UnityLoader.js file that is generated from the build rather than the template system.
    This has a load of hard coded messages such as the error displays for non compatible browsers like ...
    and the really helpful

    heh

    If there's a pre-build version of this file that Unity uses for the build then could also add my own handling of unsupported browsers etc. without having to edit the generated and obfuscated one each time after a build.
     
  4. pchuri

    pchuri

    Joined:
    Aug 18, 2014
    Posts:
    12
  5. srmatthe

    srmatthe

    Joined:
    May 15, 2016
    Posts:
    11
    Cheers, I hadn't seen that custom compatability check one so that would cover part of it.

    The other main reason for wanting to find the original version of the loader is that all of the messages, including the loading statuses of downloading, preparing, running etc are all hard coded in English as well. Any thoughts on those ?
     
  6. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    You can define your own error handler as well, (also documented in http://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html) and use localized strings for that. You could just copy the one from UnityLoader.js, and modify it.

    I guess that still leaves the strings printed to the development console. Those are not really meant for end user consumptions, so I'm not sure if there is much value in localizing those?
     
  7. srmatthe

    srmatthe

    Joined:
    May 15, 2016
    Posts:
    11
    Hiya, it might be me miscommunicating.

    I run a custom template and UnityProgress.js that pulls the loading status messages into the display for the player. We can be running across some slow links so it's useful for them to see how much they have downloaded, how much is left and what stage of the loader they are at.

    This takes the status messages from within the UnityLoader but these are all hard coded in English. There's a few options for what I wanted to do such as run a script afterwards to search and replace within the file or do some search and replace in the UnityProgress.js.

    Obviously it'd be far easier to be able to modify the base UnityLoader.js before it was populated with the build specific info and minified in the same way templates are handled and how I currently do it albeit after the event.


    If it's not available to be modified or if it's generated from somewhere deeper within then that's fine, I'll fudge something up to handle it instead although it would be useful for anyone using a custom loader with text status display. Maybe add it in as part of the module config as well ?
     
  8. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    You will find the files you want in PlaybackEngines/WebGLSupport/BuildTools/UnityConfig in your Unity install. Modifying these should work, but it is unsupported, and those changes will be local to your Unity install. There is no way to override these files in your project.
     
    tonialatalo likes this.
  9. srmatthe

    srmatthe

    Joined:
    May 15, 2016
    Posts:
    11
    Great stuff.
    Thanks for that Jonas.

    For anyone else looking it appears the various texts that are displayed when working off a custom loader base, (such as https://ocias.com/blog/unity-webgl-custom-progress-bar/ ), are in the following files.


    "Preparing..." - UnityModuleSetup.js
    "Downloading (0.0/1)" - UnityModuleSetup.js
    "Downloading data... (" - decompress.js
    "Downloading data..." - decompress.js
    "Running..." - Emscripten\postamble.js
     
  10. TOES

    TOES

    Joined:
    Jun 23, 2017
    Posts:
    134
    If you make a development build the UnityLoader.js file will be non-minified.
     
    SubZtep and LaurieAnnis like this.
  11. mayurpathak888

    mayurpathak888

    Joined:
    May 31, 2018
    Posts:
    4
    can we change unityLoader.js after build unity webgl application with some minnor changes in file is applied in project or not


    So please friends Help me Out.
     
  12. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,070
  13. mayurpathak888

    mayurpathak888

    Joined:
    May 31, 2018
    Posts:
    4


    How i can pass the parameters in unity WebGl using wegconfig or appconfig after buide
     
  14. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,070
    Write a C# editor script that does what you want to achieve. Have that be triggered after Unity finishes a build as described in the manual.
     
  15. UDN_08a62c30-cdb1-4e59-bb48-acda29f9e582

    UDN_08a62c30-cdb1-4e59-bb48-acda29f9e582

    Joined:
    Jun 19, 2018
    Posts:
    23
    I removed gzip and brotli decompressors from UnityLoader.js. Also I did not find any using of
    UnityLoader.Cryptography.crc32 or UnityLoader.Cryptography.sha1.
    My min file is 39kb instead of 155kb now.

    Initial loading of web page is pretty important thing to ignore.
     
  16. anastrophe

    anastrophe

    Joined:
    Feb 8, 2017
    Posts:
    9
    Can you share your new UnityLoader.js?
     
  17. UDN_08a62c30-cdb1-4e59-bb48-acda29f9e582

    UDN_08a62c30-cdb1-4e59-bb48-acda29f9e582

    Joined:
    Jun 19, 2018
    Posts:
    23
    Novack likes this.
  18. zakarialouqdyeme

    zakarialouqdyeme

    Joined:
    Jan 12, 2019
    Posts:
    1
    Go to your gameInstance inside index.html after build then paste the same code after
    var gameInstance = UnityLoader.instantiate("gameContainer", "pathTo Your Json File",Replace This With The Code down below);

    Code To Paste:
    {
    compatibilityCheck: function (unityInstance, onsuccess, onerror) {
    if (!UnityLoader.SystemInfo.hasWebGL) {
    unityInstance.popup("Your browser does not support WebGL",
    [{text: "OK", callback: onerror}]);
    } else if (UnityLoader.SystemInfo.mobile) {
    onsuccess();
    // unityInstance.popup("Please note that Unity WebGL is not currently supported on mobiles. Press OK if you wish to continue anyway.",
    //[{text: "OK", callback: onsuccess}]);
    } else if (["Edge", "Firefox", "Chrome", "Safari"].indexOf(UnityLoader.SystemInfo.browser) == -1) {
    unityInstance.popup("Please note that your browser is not currently supported for this Unity WebGL content. Press OK if you wish to continue anyway.",
    [{text: "OK", callback: onsuccess}]);
    } else {
    onsuccess();
    }
    },

    });
     
  19. lucifer0

    lucifer0

    Joined:
    Jul 9, 2020
    Posts:
    1
    The application loading speed of webgl platform is very slow after it is released. The main drag on the speed is the file untiyweb. Does anyone have a solution
     
  20. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,598
    Turn on data caching