is there a script to check if an object is active or inactive?
something like
if ( gamaeObject =active) { then blah blah blah; }
is there a script to check if an object is active or inactive?
something like
if ( gamaeObject =active) { then blah blah blah; }
As of Unity 4.0 gameObject.active is obsolete and is replaced by gameObject.activeSelf
Source:
http://docs.unity3d.com/Documentation/Manual/UpgradeGuide3540.html
if (gameObject.active)
specifically. Im wanting to check if a certain gameobject is active, and then act upon whether it is on or off. like can i check if a gameobject with a tag is active?
– PadgesYour original post shows that you already know how to evaluate a conditional and then act upon the result, so just do that, except with the conditional that Eric showed you.
– j_y_kthe object im looking to access is froma separate gameobject. i need to know how to do something like if (gameobject.Deagle.Active) { act; }
– PadgesYou can use “GameObject.activeSelf”: The local active state of this GameObject.
Link: Unity - Scripting API: GameObject.activeSelf
if(GameObject.activeSelf)
{
print("GameObject is Active");
}
You actually want to use
– youblistermypaintgameObject.activeInHierarchyto get the same behavior asgameObject.active. See http://answers.unity3d.com/questions/543560/does-active-getter-default-to-activeself-or-to-act.html.