I have a 3D text object called “Menu_Text”, and I’m trying to get it to change when the mouse moves over a plane. This is what I have:
function OnMouseEnter () {
var textMesh : TextMesh = GameObject.GetComponent("Menu_Text");
textMesh.text = "Blah";
}
I get this error:
Assets/Scripts/NewBehaviourScript.js(2,44): BCE0020: An instance of type ‘UnityEngine.Component’ is required to access non static member ‘GetComponent’.
I don’t understand?
EDIT
var myClip : AudioClip;
var Message : String;
function OnMouseEnter() {
audio.PlayOneShot(myClip);
var Thing : TextMesh = GetComponent("TextMesh");
Thing.text = Message;
}
This is the script as of now.