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. The 2023.1 beta is now available for testing. To find out what's new, have a look at our 2023.1 feature highlights.
    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:
    30
    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:
    128
    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);