Version 2.1.0.0

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)]
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 methodName)
Parameters
System.String methodName

The name of the method to draw the value.

Fields

MethodName
Name of the custom drawer method.
public string MethodName

This website is brand new and built with the Odin 2.1 beta in mind. This means you might discover some features such as attribute expressions that are only available in the beta.

You can download the 2.1 beta from here and read the patch-notes here.