CustomValueDrawerAttribute

Instead of making a new attribute, and a new drawer, for a one-time thing, you can with this attribute, make a method that acts as a custom property drawer. These drawers will out of the box have support for undo/redo and multi-selection.

namespace Sirenix.OdinInspector
{
[AttributeUsageAttribute((AttributeTargets)32767, AllowMultiple = False, Inherited = True)]
public class CustomValueDrawerAttribute : Attribute
}

Requirements

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector
Version: 2.0.0.0

Fields

Return Type Definition Description
string MethodName Name of the custom drawer method.

Constructors

Definition Description
CustomValueDrawerAttribute(string) Instead of making a new attribute, and a new drawer, for a one-time thing, you can with this attribute, make a method that acts as a custom property drawer. These drawers will out of the box have support for undo/redo and multi-selection.

Example

Usage:
public class CustomDrawerExamples : MonoBehaviour
{
    public float From = 2, To = 7;

    [CustomValueDrawer("MyStaticCustomDrawerStatic")]
    public float CustomDrawerStatic;

    [CustomValueDrawer("MyStaticCustomDrawerInstance")]
    public float CustomDrawerInstance;

    [CustomValueDrawer("MyStaticCustomDrawerArray")]
    public float[] CustomDrawerArray;

#if UNITY_EDITOR

    private static float MyStaticCustomDrawerStatic(float value, GUIContent label)
    {
        return EditorGUILayout.Slider(value, 0f, 10f);
    }

    private float MyStaticCustomDrawerInstance(float value, GUIContent label)
    {
        return EditorGUILayout.Slider(value, this.From, this.To);
    }

    private float MyStaticCustomDrawerArray(float value, GUIContent label)
    {
        return EditorGUILayout.Slider(value, this.From, this.To);
    }

#endif
}