Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Calling functions in .js file from c#

Discussion in 'WebGL' started by MansyrevAY, Sep 4, 2020.

  1. MansyrevAY

    MansyrevAY

    Joined:
    Nov 10, 2016
    Posts:
    14
    Hey! I have an sdk in a form of a .js file with a bunch of code (1k lines approx) which I need to use in my project. Is there any way to do that without converting file to .jslib or rewriting the whole thing in c#?
     
  2. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    491
    Yes, you can add the scripts to the index.html with the script tag, and then you can use them in the .jslib, as you'd use in the index.html. Maybe it'll only work if you make sure to use the code after the unity instance is created though.
     
    De-Panther likes this.
  3. MansyrevAY

    MansyrevAY

    Joined:
    Nov 10, 2016
    Posts:
    14
    Worked like a charm. Confused that I haven't seen this advice anywhere else, thanks a lot!
     
    Marks4 likes this.