DrawHandle Attribute

Draws a handle for the appropriate type

Parameters:
  • float red: Red amount

  • float green: Green amount

  • float blue: Blue amount

  • string hexColor: The color in hexadecimal

  • optional, GUIColor color: The color of the handle

  • optional, Space handleSpace: In which coordinate space to place the handle

Note

The DrawHandle Attribute can only be used on int, float, Vector2, Vector2Int, Vector3, Vector3Int, Bounds and SimpleTransform fields on GameObjects

Example:

using UnityEngine;
using EditorAttributes;

public class AttributesExample : MonoBehaviour
{
        [SerializeField, DrawHandle] private float floatField;
        [SerializeField, DrawHandle] private Vector3 vectorField;
        [SerializeField, DrawHandle(GUIColor.Red)] private Bounds boundsField;
}
../../_images/DrawHandle01.png

Here are handles for each supported type:

  • int and float types

../../_images/DrawHandle02.gif
  • Vector types

../../_images/DrawHandle03.gif
  • Rect types

../../_images/DrawHandle07.gif
  • Bounds types

../../_images/DrawHandle04.gif
  • SimpleTransform type

../../_images/DrawHandle05.gif

By default the handles are in world space but you can also put them in local space by setting the handleSpace parameter:

using UnityEngine;
using EditorAttributes;

public class AttributesExample : MonoBehaviour
{
        [SerializeField, DrawHandle(handleSpace: Space.Self)] private Vector3[] waypoints;
}
../../_images/DrawHandle06.gif

Note

Vector2Int and Vector3Int handles don’t support local space.