# Awake()

> Unity calls Awake when loading an instance of a script component.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)

```csharp
public void Awake()
```

### Remarks

Unity calls `Awake` on `MonoBehaviour` script components in the following scenarios: \* The GameObject the script is attached to is active in the Hierarchy ([GameObject.activeInHierarchy](/engine/6000.0/script-reference/unityengine/gameobject/activeinhierarchy.md) == `true`) and initializes on scene load. \* The GameObject the script is attached to goes from inactive ([GameObject.activeInHierarchy](/engine/6000.0/script-reference/unityengine/gameobject/activeinhierarchy.md) == `false`) to active ([GameObject.activeInHierarchy](/engine/6000.0/script-reference/unityengine/gameobject/activeinhierarchy.md) == `true`). \* After initialization of a parent GameObject created with [Object.Instantiate](/engine/6000.0/script-reference/unityengine/object/instantiate.md). Unity calls `Awake` regardless of the value of [Behaviour.enabled](/engine/6000.0/script-reference/unityengine/behaviour/enabled.md) for the script component itself, as long as the other conditions are met. Use `Awake` to initialize variables or states before the application starts. Unity calls `Awake` only once during the lifetime of the script instance. A script's lifetime lasts until the Scene that contains it is unloaded. If the scene is loaded again, Unity loads the script instance again and calls `Awake` again. If the scene is loaded multiple times additively, Unity loads several script instances, and `Awake` is called once for each instance. For active GameObjects in a scene, Unity calls `Awake` after all active GameObjects in the scene are initialized, so you can safely use methods such as [GameObject.FindWithTag](/engine/6000.0/script-reference/unityengine/gameobject/findwithtag.md) to query other GameObjects. The order in which Unity calls each GameObject's `Awake` is not deterministic and you can't rely on `Awake` being called on one GameObject before or after another. For example, don't assume that a reference set up by one GameObject's `Awake` will be usable in another GameObject's `Awake`. Instead, you should use `Awake` to set up references between scripts, and use Start, which is called after all `Awake` calls are finished, to pass any information back and forth. `Awake` is always called before any Start functions. This allows you to order initialization of scripts. `Awake` is called even if the script is a disabled component of an active GameObject. If a script component's `Awake` throws an exception, Unity disables the component. `Awake` cannot act as a coroutine. Use `Awake` instead of the constructor for initialization, as the serialized state of the component is undefined at construction time. `Awake` is called once, just like the constructor.

### Examples

```csharp

using UnityEngine;

public class ExampleClass : MonoBehaviour
{
    private GameObject target;

    void Awake()
    {
        target = GameObject.FindWithTag("Player");
    }
}
```
