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. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

[Question-Solved but not for release] Access class cid from string

Discussion in 'Project Tiny' started by LauraLaureus, Dec 19, 2018.

  1. LauraLaureus

    LauraLaureus

    Joined:
    Oct 5, 2018
    Posts:
    9
    Hi everyone!

    I have been playing with the Tweens module and since providing the cid of the class to tween is mandatory and I want to create my systems as generic as possible I would like to ask:

    Does exists a way to access a class type from a string?

    Ideally my component has the full name of the class and the system read it and gets the cid to add to the TweenComponent.

    I tried the solution provided here with no luck: https://stackoverflow.com/questions...s-reflection-for-typescript/15339429#15339429

    Thanks in advantage
     
  2. LauraLaureus

    LauraLaureus

    Joined:
    Oct 5, 2018
    Posts:
    9
    After some "in-navigator" research I found a solution:

    Code (JavaScript):
    1. window["_ut_Core2D_TransformLocalPosition_cid"]();
    Keep atention to the fact we have to replace '.' in class name to '_'.

    I hope it helps to somebody.