I already tried unsuccessfully to apply this:
http://unity3d.com/support/documentation/ScriptReference/GameObject.GetComponent.html
I always get this error:
NullReferenceException: Object reference not set to an instance of an object
my script:
Script “Goal” on another Object:
var Gg;
function OnTriggerEnter ( coll_1: Collider )
{
Gg++;
}
Script Gui :
var disp_text = "Goal Num: ";
function OnGUI() {
var Goal_obj : Goal = gameObject.GetComponent(Goal);
GUI.Label (Rect(20,10,200,200),disp_text+Goal_obj.Gg);
}
What I want to do is get the value of Gc Gameobject and view it from another function via GUI
Thanks in advance