Unlike GameObject.activeSelf, this also checks if any parent GameObjects affect the GameObject’s currently active state.

When a parent GameObject is deactivated, its children are usually marked as active even though they are not visible, so they are still active according to GameObject.activeSelf. However, GameObject.activeInHierarchy ensures this doesn’t happen by instead checking that the GameObject hasn’t been deactivated by a member in its hierarchy.

//This script shows how activeInHierarchy differs from activeSelf. Use the toggle to alter the parent and child GameObject’s active states. This makes it output the child GameObject’s state in the console.
//It also shows how activeSelf outputs that the child GameObject is active when the parent is not, while the activeInHierarchy lists the child GameObject as inactive.

//Find out if the GameObject is active in the Game and checks if this state has been output to the console
if (m_HierarchyOutput == false)
{
//Output the state of the GameObject’s activity if it hasn't already been output
Debug.Log("Object Active : " + m_ChildObject.activeInHierarchy);
//The state of the GameObject is output already, so no need to do it again
m_HierarchyOutput = true;
}
//Check to see if the assigned GameObject is active despite parent GameObject's status
if (m_ChildObject.activeSelf &amp;&amp; m_SelfOutput == false)
{
//Output the message if the GameObject is still active
Debug.Log("Child Active, parent might not be");
//You no longer need to output the message
m_SelfOutput = true;
}
}