Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Calling TypeScript functions from JavaScript on web.

Discussion in 'Project Tiny' started by Vecna, Apr 24, 2019.

  1. Vecna

    Vecna

    Joined:
    Apr 2, 2014
    Posts:
    32
    I want to communicate from my website (JavaScript) to Unity. With WebGL you used to use "SendMessage('MyGameObject', 'MyFunction');" but how would you do that with ECS/Tiny?
     
  2. Rupture13

    Rupture13

    Joined:
    Apr 12, 2016
    Posts:
    131
    You can call your TypeScript functions directly from JavaScript.
    If the functions are not static, you need to get instances of an entity to call the functions on.
    If the functions are static, you can call them on the class the function exists in: e.g.
    game.MyStaticUtilClass.MyFunction(myParameter);