# CubeHandleCap(int, Vector3, Quaternion, float, EventType)

> Draw a cube handle. Pass this into handle functions.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.7/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
public static void CubeHandleCap(int controlID, Vector3 position, Quaternion rotation, float size, EventType eventType)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The control ID for the handle.**** (\[Vector3]\(/engine/6000.7/script-reference/unityengine/vector3)): The position of the handle in the space of [Handles.matrix](/engine/6000.7/script-reference/unityeditor/handles/matrix.md).**** (\[Quaternion]\(/engine/6000.7/script-reference/unityengine/quaternion)): The rotation of the handle in the space of [Handles.matrix](/engine/6000.7/script-reference/unityeditor/handles/matrix.md).**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The size of the handle in the space of [Handles.matrix](/engine/6000.7/script-reference/unityeditor/handles/matrix.md). Use [HandleUtility.GetHandleSize](/engine/6000.7/script-reference/unityeditor/handleutility/gethandlesize.md) if you want a constant screen-space size.**** (\[EventType]\(/engine/6000.7/script-reference/unityengine/eventtype)): Event type for the handle to act upon. By design it handles [EventType.Layout](/engine/6000.7/script-reference/unityengine/eventtype/layout.md) and [EventType.Repaint](/engine/6000.7/script-reference/unityengine/eventtype/repaint.md) events.

### Remarks

On [EventType.Layout](/engine/6000.7/script-reference/unityengine/eventtype/layout.md) event, calculates handle distance to mouse and calls [HandleUtility.AddControl](/engine/6000.7/script-reference/unityeditor/handleutility/addcontrol.md) accordingly.

On [EventType.Repaint](/engine/6000.7/script-reference/unityengine/eventtype/repaint.md) event, draws the handle shape.

![CubeCap (CubeHandleCap(int, Vector3, Quaternion, float, EventType))](/api/media?file=/engine/6000.7/media/images/CubeCap.png)

*Cube Handle Cap in the Scene View.*

Add the following script to your Assets folder as CubeExample.cs and add the CubeExample component to an object in the Scene.

```csharp
using UnityEngine;

public class CubeExample : MonoBehaviour {}
```

Add the following script to Assets/Editor as CubeExampleEditor.cs and select the object with the CubeExample component.

```csharp
using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(CubeExample))]
public class CubeExampleEditor : Editor
{
    float size = 1f;

    protected virtual void OnSceneGUI()
    {
        if (Event.current.type == EventType.Repaint)
        {
            Transform transform = ((CubeExample)target).transform;
            Handles.color = Handles.xAxisColor;
            Handles.CubeHandleCap(
                0,
                transform.position + new Vector3(3f, 0f, 0f),
                transform.rotation * Quaternion.LookRotation(Vector3.right),
                size,
                EventType.Repaint
            );
            Handles.color = Handles.yAxisColor;
            Handles.CubeHandleCap(
                0,
                transform.position + new Vector3(0f, 3f, 0f),
                transform.rotation * Quaternion.LookRotation(Vector3.up),
                size,
                EventType.Repaint
            );
            Handles.color = Handles.zAxisColor;
            Handles.CubeHandleCap(
                0,
                transform.position + new Vector3(0f, 0f, 3f),
                transform.rotation * Quaternion.LookRotation(Vector3.forward),
                size,
                EventType.Repaint
            );
        }
    }
}
```
