Setting gameobject to be active

Hi

I have a GUITexture (say TexA) on the screen. I am using it as a button - as soon as I click on it, Id like to display another texture, say TexB, (as a popup button) on the screen. Here are the 2 scripts I have with the error-code included:

//Script1: Attached to TexA
var TexA: GUITexture;
var pop : GameObject; //pop is linked to TexB

function Update()
{

for ( var evt1 : iPhoneTouch in iPhoneInput.touches )
{
var texTrue = TexA.HitTest(Input.mousePosition);

if( evt1.phase == iPhoneTouchPhase.Ended || evt1.phase == iPhoneTouchPhase.Began )
{
if( TexTrue )
{
pop.active = true; //THIS LINE CAUSES SCREEN TO HANG
}

}
}
}

//Script attached to TexB

function Start () {
gameObject.active = false;
}

The error line causes the screen to hang. I am not sure what I am doing wrong here.
Thanks
Bi

Hello :slight_smile:

Are you accessing that object when you deactivate it?, if you are, that’s what is creating your hang :slight_smile:

I thought you only used .active on a gameobject?

var TexA: GUITexture;

would be…

var TexA: GameObject;

However, it appears the first thing you do with the object is turn it off anyway… Or did I misread?