Version 3.3.1.2

Odin has a dedicated attribute overview with examples

CustomValueDrawerAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = false, Inherited = true)]
[Conditional("UNITY_EDITOR")]
public class CustomValueDrawerAttribute : Attribute, _Attribute
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.
Inheritance
  • System.Object
  • System.Attribute
  • CustomValueDrawerAttribute
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
}

Constructors

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.
public CustomValueDrawerAttribute(string action)
Parameters
System.String action

A resolved string that defines the custom drawer action to take, such as an expression or method invocation.

Fields

Action
A resolved string that defines the custom drawer action to take, such as an expression or method invocation.
public string Action