check if a gameobject is active unity code example

Example 1: check if gameobject is active

if (gameObject.activeSelf)
{
	// this happens when object is active
}

Example 2: unity check if gameobject is active

// To check if a GameObject is active:
gameObject.activeSelf;

Example 3: how to check if an object is active in unity

if (myGameObject.activeSelf)