how to get a value from a C# script in a js.

I have two script----“cameraController.js” and “airplaneController.cs”. Both are attached to a single GameOject.

In the “airplaneController” class there is a public function getInfo();

I have tried “var airplaneControllert = gameObject.GetComponent(“airplaneController”);” and “var airplaneControllert:Component;” with drugging the cs script to the component in Inspector. But both of them failed. I can’t get getInfo() or any other elements of class “airplaneController” in the js script.

What’s wrong?

CSharp and JS can’t see each other at compile time (different compilers are used for each language), but already compiled scripts can be seen by any language. If you place the C# script in Plugins or StandardAssets, and the JS script in another Assets folder (Assets/Scripts, for example), the C# script will be compiled in the “first wave”, thus the JS script will know it and compile ok. And in code:

 var csharpcomponent:CSharpComp;
 function Start(){
  csharpcomponent = this.gameObject.GetComponent(CSharpComp);

But this is bad practice to have a project with both JS and C#. You should consider translating all scripts to one unique language. I hope that it will help you.