# isActiveAndEnabled

> Checks whether a component is enabled, attached to a GameObject that is active in the hierarchy, and the component's OnEnable has been called.

## Definition

* **Type:** Property
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public bool isActiveAndEnabled { get; }
```

### Remarks

`Behaviour.isActiveAndEnabled` returns `true` only if all the following conditions are met:

* The GameObject that the Behaviour is attached to is active in the hierarchy ([GameObject.activeInHierarchy](/engine/6000.5/script-reference/unityengine/gameobject/activeinhierarchy.md) == `true`).
* The Behaviour is enabled ([Behaviour.enabled](/engine/6000.5/script-reference/unityengine/behaviour/enabled.md) == `true`).
* The component's [MonoBehaviour.OnEnable()](/engine/6000.5/script-reference/unityengine/monobehaviour/onenable.md) method has been called.

**Important:** Even if a component is enabled and its GameObject is active, `isActiveAndEnabled` still returns `false` until `OnEnable` is called on the component. This is by design in Unity's scripting lifecyle. For more information, refer to [Event function execution order](/engine/6000.5/manual/scripting/managing-update-order/execution-order.md) in the User Manual.

### Examples

```csharp
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Example : MonoBehaviour
{
    public Image pauseMenu;

    public void Update()
    {
        //Checks if the GameObject and Image are active and enabled.
        if (pauseMenu.isActiveAndEnabled)
        {
            //If the Image is enabled, print "Enabled" in the console. Stops when the image or GameObject is disabled.
            Debug.Log("Enabled");
        }
    }
}
```
