Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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:
    278
  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:
    278
    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.