docs.unity3d.com
    Show / Hide Table of Contents

    Class VolumeParameterDrawer

    A base class to implement to draw custom editors for custom VolumeParameter. You must use a VolumeParameterDrawerAttribute to let the editor know which parameter this drawer is for.

    Inheritance
    Object
    VolumeParameterDrawer
    Namespace: UnityEditor.Rendering
    Syntax
    public abstract class VolumeParameterDrawer
    Remarks

    If you do not provide a custom editor for a VolumeParameter, Unity uses the buil-in property drawers to draw the property as-is.

    Examples

    Here's an example about how ClampedFloatParameter is implemented:

    [VolumeParameterDrawer(typeof(ClampedFloatParameter))]
    class ClampedFloatParameterDrawer : VolumeParameterDrawer
    {
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;
    
            if (value.propertyType != SerializedPropertyType.Float)
                return false;
    
            var o = parameter.GetObjectRef<ClampedFloatParameter>();
            EditorGUILayout.Slider(value, o.min, o.max, title);
            value.floatValue = Mathf.Clamp(value.floatValue, o.min, o.max);
            return true;
        }
    }

    Methods

    IsAutoProperty()

    Override this and return false if you want to customize the position of the override checkbox. If you don't, Unity automatically draws the checkbox and puts the property content in a horizontal scope.

    Declaration
    public virtual bool IsAutoProperty()
    Returns
    Type Description
    Boolean

    false if the override checkbox position is customized, true otherwise

    OnGUI(SerializedDataParameter, GUIContent)

    Draws the parameter in the editor. If the input parameter is invalid you should return false so that Unity displays the default editor for this parameter.

    Declaration
    public abstract bool OnGUI(SerializedDataParameter parameter, GUIContent title)
    Parameters
    Type Name Description
    SerializedDataParameter parameter

    The parameter to draw.

    GUIContent title

    The label and tooltip of the parameter.

    Returns
    Type Description
    Boolean

    true if the input parameter is valid, false otherwise in which case Unity will revert to the default editor for this parameter

    Extension Methods

    ReflectionUtils.Invoke(Object, String, Object[])
    ReflectionUtils.SetField(Object, String, Object)
    ReflectionUtils.GetField(Object, String)
    ReflectionUtils.GetFields(Object)

    See Also

    VolumeParameterDrawerAttribute
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023