Get a variable from a C# script in a JS script.

Hi, as simple as that. I have a JS and i want to pull in a variable from a C# script.

This is how I pull it in from other C# scripts and that seems to work fine.

the target game object is called Speed
the target script is called SpeedEngine
the target variable is called tSpeed.

GameObject Ospeed = GameObject.Find("Speed");
SpeedEngine speedEngine = Ospeed.GetComponent<SpeedEngine>();
inSpeed = speedEngine.tSpeed;

I’m not a JS guy and i’m not sure if its even possible to pull variables between different languages…

Any ideas?

Thanks!

The answers you seek are found here. It’s about where the files are located in your asset hierarchy.
http://docs.unity3d.com/412/Documentation/ScriptReference/index.Script_compilation_28Advanced29.html

But the “real” answer is, use C# instead. :wink: