I am sure this is very simple, but I am having trouble getting hold of variables in a C# script, accessed from javascript. I get this error “BCE0018: The name ‘FlyControl’ does not denote a valid type.”
From this line of code…
var GetFlyControl : FlyControl = GetComponent (FlyControl);
The script is called FlyControl, and exists on the same game object. There are a few variables I need (a few public floats and bools). I know it is easier to stick to just one language, but I have built an entire system around JS, and cannot convert this new bit from C# due to lack of time and knowledge. Its the only C# thing in the whole project!
See the advanced documentations on compilation order. It will explain you all the related things on how to do it.
C# and JS generally don’t know of the others existance, all they know is that they are part of an already compiled .net assembly, as such the other side must be compiled in an earlier step.
Ok so I am getting no error messages from the following line of code, which is due to rearranging the C# scripting into StandardAssets/Editor (thanks for that).
var GetFlyControl = GetComponent("FlyControl");
However, whenever I try to access any of the variables (eg a simple boolean like “if(GetFlyControl.paused){}”), I get the following error message.
and I’m not sure why. It only gives errors whenever I try to access the variables. At the moment, they are public bools (eg. public bool paused = false;). Any thoughts?
that would never cause an error as it is not checked at compile time at all. Thats why its commonly avoided. remove the “”, that will give you compile time type checking.
I guess you don’t have a FlyControl monobehaviour on the same object. Perhaps you have it on a child or different object