Search Unity

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:
    23
    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:
    78
    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);