I do not receive this error message if the GameObject is Static but how do you assign a variable that is Not Static or is a moving GameObject? I’m trying to avoid using a 'Find" script.
here’s what the message says.
"UnassignedReference Exception: The variable myGUIPlane of ‘GUIPlaneOn’ has not been assigned. You probably need to assign the myGUIPlane variable of the GUIPlaneOn script in the inspector.
So I dragged and dropped the ‘GUIPlane’ gameObject into the variable slot in the inspector(little icon appears) but then I get an error message. What am I doing wrong?
I thought that by dragging and dropping the gameObject into the variable slot that it is “assigned” creating a reference to that object. But it’s not working with moving objects that can’t be Static in my game… What am I doing wrong? Any suggestions? Thanx
Here’s 2 scripts. The ‘Find’ script works with no error messages. The other does not.
this script works
function OnTriggerEnter( myzTrigger : Collider){
if(myzTrigger.gameObject.name == "tum1-1"){
var myGUIPlane : MeshRenderer =gameObject.Find("GUIPlane").GetComponent(MeshRenderer);
myGUIPlane.enabled = true;
}
}
This script gives me the error;
var myGUIPlane : MeshRenderer;
function OnTriggerEnter( myzTrigger : Collider){
if(myzTrigger.gameObject.name == "tum1-1"){
myGUIPlane.enabled = true;
}
}
I’d like to use the second script. Any suggestions? thanx