Since Unity changed .active I use .activeSelf in GUI button.
First I tried GameObject.SetActive(!GameObject.activeSelf);
It active my object from false to true. But when I press it the second time the object stays true. ! seems not working.
So I tried
if (GameObject.activeSelf){
GameObject.SetActive(false);
Debug.Log("t"+GameObject.activeSelf);
}
else {
GameObject.SetActive(true);
Debug.Log("f"+GameObject.activeSelf);
}
It now always give me “fTrue”. the object can never change to deactive again. the IF statement is even not working correctly.
I’ve tried GameObject.SetActive(false); it works fine.
GameObject is a type… make sure you are using a reference
Hi James, sorry my gameobject has a long weird name. so I replaced it and use GameObject to not confuse people.
other than that, do you have any idea of the SetActive function?
What are you trying to do? Turn it on and off?
right. just make a button to switch it on and off.
it was all right when i used SetActiveRecursively in unity3.5. But in unity4 just messed up.
kind of. Its actually a function I defined. Then I made a GUI button to call this function.
Not sure what you have going on, but I have been using “enabled”.
Hi guys, I just did a test. the function it self was fine. Everything are actually using a metaio AR plugin. That is messing up with all my objects activity. Working on other tests now.