hey how do i enable and disable a guitext object? i have

hey how do i enable and disable a guitext object? i have var Guitext : GameObject; //for gui text

Guitext = GameObject.Find("GUI Text"); Guitext.guiText.enabled = false;

then re-abling it i have

Guitext.guiText.enabled = true;

i have disable it no problem, however i could not reenable it need help

The problem is that GameObject.Find doesn't find objects after they have been disabled.

One solution is, keep an instance variable set to that object, so you don't have to Find it again to enable it.

Another approach is to keep your own list of objects that you might want to find. (This list can contain any objects you want, active or inactive, gui or other.) Then you can search that array instead of calling Find.

See: http://answers.unity3d.com/questions/14178/cannot-toggle-active-on-gameobjects-that-are-inactive

There's no reason why this shouldn't work. The only place where something wrong could happen is that if

Guitext.guiText.enabled = true;

never gets called. Put a

Debug.log("whatever");

Right before or after to see if it gets called, and if not, try to figure out why this is (for instance inside an Update function of an object that is disabled or something)

var textObject : GUIText;

function OnMouseOver () { textObject.text = gameObject.name; textObject.GetComponent(GUIText).enabled = true; }

function OnMouseExit () { textObject.text = gameObject.name; textObject.GetComponent(GUIText).enabled = false; }

I’m no coder - far from it - but I modified another script for toggling the visibility of an object via a key (Tab in this case) and it works perfectly:

#pragma strict

function Update() {

if (Input.GetKeyDown(KeyCode.Tab)) {
    // toggle visibility:
    guiText.enabled = !guiText.enabled;
}

}