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

Question Upgrading WebGL from 2019 to 2022 Module.asmLibraryArg missing

Discussion in 'Web' started by developerarreterra, Mar 2, 2023.

  1. developerarreterra

    developerarreterra

    Joined:
    Oct 8, 2018
    Posts:
    17
    Hi,

    We're currently upgrading our project from Unity 2019 to Unity 2022.1.15.
    We have a lot of communication between the browser and the Unity player.
    In the Unity project we have a javascript.jslib with all the function connected in Unity.
    In the HTML project we normally call our Unity function like this:
    Code (JavaScript):
    1. unityInstance.Module.asmLibraryArg._functionToCall(JSON);
    it seems the asmLibraryArg can't be found.
    We've tried several other solutions, and we can find the function when we look into the source in the browser.

    thank you in advance!
     
  2. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    264
  3. korinVR

    korinVR

    Joined:
    Jul 7, 2012
    Posts:
    34
    Hi, I'm stuck on this too.
    I want to call a .jslib function from JavaScript on my browser page, but on Unity 2022.1.24 and 2022.2.9, Module.asmLibraryArg is undefined and I can't find an alternative field in the Module object.
    Is this now completely omitted?
     
  4. unityruba

    unityruba

    Unity Technologies

    Joined:
    Nov 6, 2020
    Posts:
    264
    Apologies, I misunderstood the original question (this applies to @developerarreterra as well )

    If you'd like to call Unity scripts from JavaScript and JavaScript from Unity scripts, then please refer to the docs right here, you won't be using Module.asmLibraryArg, since compiling to asm.js is no longer supported. If you're using any plugins that use .amLibraryArg, you'll also run into problems there.

    Emscripten's docs also describe the Module object in more detail and how to interact with it:

    https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html
    https://emscripten.org/docs/api_reference/module.html#module

    Please let me know if you have any further questions.