# TouchPhase

> Describes the phase of a finger touch.

## Definition

* **Type:** Enum
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.InputLegacyModule

```csharp
public enum TouchPhase
```

## Remarks

TouchPhase is an enum type that contains the states of possible finger touches. The states represent each action the finger can take on the most recent frame update. Because the device tracks a touch over its lifetime, the start and end of a touch and movements in between can be reported on the frames they occur.

## Examples

```csharp
 //Attach this script to an empty GameObject
 //Create some UI Text by going to <b>Create</b>><b>UI</b>><b>Text</b>.
 //Drag this GameObject into the Text field to the Inspector window of your GameObject.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class TouchPhaseExample : MonoBehaviour
{
    public Vector2 startPos;
    public Vector2 direction;

    public Text m_Text;
    string message;

    void Update()
    {
        //Update the Text on the screen depending on current TouchPhase, and the current direction vector
        m_Text.text = "Touch : " + message + "in direction" + direction;

        // Track a single touch as a direction control.
        if (Input.touchCount > 0)
        {
            Touch touch = Input.GetTouch(0);

            // Handle finger movements based on TouchPhase
            switch (touch.phase)
            {
                //When a touch has first been detected, change the message and record the starting position
                case TouchPhase.Began:
                    // Record initial touch position.
                    startPos = touch.position;
                    message = "Begun ";
                    break;

                //Determine if the touch is a moving touch
                case TouchPhase.Moved:
                    // Determine direction by comparing the current touch position with the initial one
                    direction = touch.position - startPos;
                    message = "Moving ";
                    break;

                case TouchPhase.Ended:
                    // Report that the touch has ended when it ends
                    message = "Ending ";
                    break;
            }
        }
    }
}
```

## Fields

| Value                                                                              | Description                                                              |
| ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| [Began](/engine/6000.7/script-reference/unityengine/touchphase/began.md)           | A finger touched the screen.                                             |
| [Canceled](/engine/6000.7/script-reference/unityengine/touchphase/canceled.md)     | The system cancelled tracking for the touch.                             |
| [Ended](/engine/6000.7/script-reference/unityengine/touchphase/ended.md)           | A finger was lifted from the screen. This is the final phase of a touch. |
| [Moved](/engine/6000.7/script-reference/unityengine/touchphase/moved.md)           | A finger moved on the screen.                                            |
| [Stationary](/engine/6000.7/script-reference/unityengine/touchphase/stationary.md) | A finger is touching the screen but hasn't moved.                        |
