Hello chaps, I have a problem trying to access a C# script component from a Java script. My code is simple…
var playerObject :GameObject;
var mouseLookScript : MouseLook;//this is the name of the script (MouseLook.Cs)
function Start()
{
playerObject=(GameObject.Find("Player"));//it finds this object no problem
mouseLookScript =playerObject.GetComponent(MouseLook);//but not this component..:(
}
But my MouseLookScript var reads as nothing in the inspector…?? ie None(MouseLook)
Do you get any error messages about MouseLook being undefined? If so, put the MouseLook.cs script inside the standard assets folder. Also, are you sure the object has a MouseLook component attached?
you must put the C# class in a build step that happens earlier than your JS compilation step so the compilation order is correct (that means putting it into folder Standard Assets - Pro Assets - Plugins basically). You can find out more about that in the advanced topic documentation
Hmm, now I have both scripts in the same folder (/customassets . This should all get compiled last right?)) and I don’t get the error but Mouselook still contains ‘none’
Actually now I have the Mouselook in standard assets (compiled first) and the other script in another script folder (compiled last). I get no error but Mouselook is still ‘none’.