# JointAngularLimitHandle

> A class for a compound handle to edit multiaxial angular motion limits in the Scene view.

## Definition

* **Type:** Class
* **Namespace:** [UnityEditor.IMGUI.Controls](/engine/6000.6/script-reference/unityeditor/imgui/controls.md)
* **Assembly:** UnityEditor

```csharp
public class JointAngularLimitHandle
```

## Remarks

![JointAngularLimitHandle (JointAngularLimitHandle)](/api/media?file=/engine/6000.6/media/images/JointAngularLimitHandle.png)

*JointAngularLimitHandle in the Scene View.*

The shapes rendered by the [JointAngularLimitHandle.DrawHandle](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/drawhandle.md) method assume that angular limits are applied first along the x-axis, then the y-axis, and finally the z-axis.

The following component defines angular limits for a [CharacterJoint](/engine/6000.6/script-reference/unityengine/characterjoint.md) to be added at run time.

```csharp
using UnityEngine;

public class JointExample : MonoBehaviour
{
    public float xMin { get { return m_XMin; } set { m_XMin = value; } }
    [SerializeField]
    float m_XMin = -45f;

    public float xMax { get { return m_XMax; } set { m_XMax = value; } }
    [SerializeField]
    float m_XMax = 45f;

    public float yMax { get { return m_YMax; } set { m_YMax = value; } }
    [SerializeField]
    float m_YMax = 45f;

    public float zMax { get { return m_ZMax; } set { m_ZMax = value; } }
    [SerializeField]
    float m_ZMax = 45f;

    protected virtual void Start()
    {
        var joint = gameObject.AddComponent<CharacterJoint>();

        var limit = joint.lowTwistLimit;
        limit.limit = m_XMin;
        joint.lowTwistLimit = limit;

        limit = joint.highTwistLimit;
        limit.limit = m_XMax;
        joint.highTwistLimit = limit;

        limit = joint.swing1Limit;
        limit.limit = m_YMax;
        joint.swing1Limit = limit;

        limit = joint.swing2Limit;
        limit.limit = m_ZMax;
        joint.swing2Limit = limit;
    }
}
```

The following Custom Editor example allows you to edit the serialized angular limits in the Scene view.

```csharp
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;

[CustomEditor(typeof(JointExample)), CanEditMultipleObjects]
public class JointExampleEditor : Editor
{
    JointAngularLimitHandle m_Handle = new JointAngularLimitHandle();

    // the OnSceneGUI callback uses the Scene view camera for drawing handles by default
    protected virtual void OnSceneGUI()
    {
        var jointExample = (JointExample)target;

        // copy the target object's data to the handle
        m_Handle.xMin = jointExample.xMin;
        m_Handle.xMax = jointExample.xMax;

        // CharacterJoint and ConfigurableJoint implement y- and z-axes symmetrically
        m_Handle.yMin = -jointExample.yMax;
        m_Handle.yMax = jointExample.yMax;

        m_Handle.zMin = -jointExample.zMax;
        m_Handle.zMax = jointExample.zMax;

        // set the handle matrix to match the object's position/rotation with a uniform scale
        Matrix4x4 handleMatrix = Matrix4x4.TRS(
            jointExample.transform.position,
            jointExample.transform.rotation,
            Vector3.one
        );

        EditorGUI.BeginChangeCheck();

        using (new Handles.DrawingScope(handleMatrix))
        {
            // maintain a constant screen-space size for the handle's radius based on the origin of the handle matrix
            m_Handle.radius = HandleUtility.GetHandleSize(Vector3.zero);

            // draw the handle
            EditorGUI.BeginChangeCheck();
            m_Handle.DrawHandle();
            if (EditorGUI.EndChangeCheck())
            {
                // record the target object before setting new values so changes can be undone/redone
                Undo.RecordObject(jointExample, "Change Joint Example Properties");

                // copy the handle's updated data back to the target object
                jointExample.xMin = m_Handle.xMin;
                jointExample.xMax = m_Handle.xMax;

                jointExample.yMax = m_Handle.yMax == jointExample.yMax ? -m_Handle.yMin : m_Handle.yMax;

                jointExample.zMax = m_Handle.zMax == jointExample.zMax ? -m_Handle.zMin : m_Handle.zMax;
            }
        }
    }
}
```

## Constructors

| Constructor                                                                                                             | Description                                                                                                                                           |
| ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| [JointAngularLimitHandle()](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/ctor.md) | Creates a new instance of the [JointAngularLimitHandle](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle.md) class. |

## Properties

| Property                                                                                                                                 | Description                                                                                                                                                                                         |
| ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [angleHandleDrawFunction](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/anglehandledrawfunction.md) | The [Handles.CapFunction](/engine/6000.6/script-reference/unityeditor/handles/capfunction.md) to use when displaying the angle control handle.                                                      |
| [angleHandleSizeFunction](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/anglehandlesizefunction.md) | The [Handles.SizeFunction](/engine/6000.6/script-reference/unityeditor/handles/sizefunction.md) to specify how large the angle control handle should be.                                            |
| [fillAlpha](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/fillalpha.md)                             | Returns or specifies the opacity to use when rendering fill shapes for the range of motion for each axis. Defaults to 0.1.                                                                          |
| [radius](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/radius.md)                                   | Returns or specifies the radius of the arc for the handle. Defaults to 1.0.                                                                                                                         |
| [wireframeAlpha](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/wireframealpha.md)                   | Returns or specifies the opacity to use for the curved lines along the outside of the arcs of motion. Defaults to 1.0.                                                                              |
| [xHandleColor](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/xhandlecolor.md)                       | Returns or specifies the color to use for the handle limiting motion around the x-axis. Defaults to [Handles.xAxisColor](/engine/6000.6/script-reference/unityeditor/handles/xaxiscolor.md).        |
| [xMax](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/xmax.md)                                       | Returns or specifies the maximum angular motion about the x-axis.                                                                                                                                   |
| [xMin](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/xmin.md)                                       | Returns or specifies the minimum angular motion about the x-axis.                                                                                                                                   |
| [xMotion](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/xmotion.md)                                 | Returns or specifies how angular motion is limited about the x-axis. Defaults to [ConfigurableJointMotion.Limited](/engine/6000.6/script-reference/unityengine/configurablejointmotion/limited.md). |
| [xRange](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/xrange.md)                                   | Returns or specifies the range of valid values for angular motion about the x-axis. Defaults to \[-180.0, 180.0].                                                                                   |
| [yHandleColor](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/yhandlecolor.md)                       | Returns or specifies the color to use for the handle limiting motion around the y-axis. Defaults to [Handles.yAxisColor](/engine/6000.6/script-reference/unityeditor/handles/yaxiscolor.md).        |
| [yMax](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/ymax.md)                                       | Returns or specifies the maximum angular motion about the y-axis.                                                                                                                                   |
| [yMin](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/ymin.md)                                       | Returns or specifies the minimum angular motion about the y-axis.                                                                                                                                   |
| [yMotion](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/ymotion.md)                                 | Returns or specifies how angular motion is limited about the y-axis. Defaults to [ConfigurableJointMotion.Limited](/engine/6000.6/script-reference/unityengine/configurablejointmotion/limited.md). |
| [yRange](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/yrange.md)                                   | Returns or specifies the range of valid values for angular motion about the y-axis. Defaults to \[-180.0, 180.0].                                                                                   |
| [zHandleColor](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/zhandlecolor.md)                       | Returns or specifies the color to use for the handle limiting motion around the z-axis. Defaults to [Handles.zAxisColor](/engine/6000.6/script-reference/unityeditor/handles/zaxiscolor.md).        |
| [zMax](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/zmax.md)                                       | Returns or specifies the maximum angular motion about the z-axis.                                                                                                                                   |
| [zMin](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/zmin.md)                                       | Returns or specifies the minimum angular motion about the z-axis.                                                                                                                                   |
| [zMotion](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/zmotion.md)                                 | Returns or specifies how angular motion is limited about the z-axis. Defaults to [ConfigurableJointMotion.Limited](/engine/6000.6/script-reference/unityengine/configurablejointmotion/limited.md). |
| [zRange](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/zrange.md)                                   | Returns or specifies the range of valid values for angular motion about the z-axis. Defaults to \[-180.0, 180.0].                                                                                   |

## Methods

| Method                                                                                                         | Description                                                                                       |
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [DrawHandle](/engine/6000.6/script-reference/unityeditor/imgui/controls/jointangularlimithandle/drawhandle.md) | A function to display this instance in the current handle camera using its current configuration. |
