Class VolumeComponentEditor | Core RP Library | 8.0.1
docs.unity3d.com
    Show / Hide Table of Contents

    Class VolumeComponentEditor

    A custom editor class that draws a VolumeComponent in the Inspector. If you do not provide a custom editor for a VolumeComponent, Unity uses the default one. You must use a VolumeComponentEditorAttribute to let the editor know which component this drawer is for.

    Inheritance
    Object
    VolumeComponentEditor
    Namespace: UnityEditor.Rendering
    Syntax
    public class VolumeComponentEditor
    Examples

    Below is an example of a custom VolumeComponent:

    using UnityEngine.Rendering;
    
    [Serializable, VolumeComponentMenu("Custom/Example Component")]
    public class ExampleComponent : VolumeComponent
    {
        public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f);
    }

    And its associated editor:

    using UnityEditor.Rendering;
    
    [VolumeComponentEditor(typeof(ExampleComponent))]
    class ExampleComponentEditor : VolumeComponentEditor
    {
        SerializedDataParameter m_Intensity;
    
        public override void OnEnable()
        {
            var o = new PropertyFetcher<ExampleComponent>(serializedObject);
            m_Intensity = Unpack(o.Find(x => x.intensity));
        }
    
        public override void OnInspectorGUI()
        {
            PropertyField(m_Intensity);
        }
    }

    Fields

    m_Inspector

    A reference to the parent editor in the Inspector.

    Declaration
    protected Editor m_Inspector
    Field Value
    Type Description
    Editor

    Properties

    activeProperty

    The serialized property of active for the component being inspected.

    Declaration
    public SerializedProperty activeProperty { get; }
    Property Value
    Type Description
    SerializedProperty

    baseProperty

    The copy of the serialized property of the VolumeComponent being inspected. Unity uses this to track whether the editor is collapsed in the Inspector or not.

    Declaration
    public SerializedProperty baseProperty { get; }
    Property Value
    Type Description
    SerializedProperty

    hasAdvancedMode

    Override this property if your editor makes use of the "More Options" feature.

    Declaration
    public virtual bool hasAdvancedMode { get; }
    Property Value
    Type Description
    Boolean

    isInAdvancedMode

    Checks if the editor currently has the "More Options" feature toggled on.

    Declaration
    public bool isInAdvancedMode { get; }
    Property Value
    Type Description
    Boolean

    serializedObject

    A SerializedObject representing the object being inspected.

    Declaration
    public SerializedObject serializedObject { get; }
    Property Value
    Type Description
    SerializedObject

    target

    Specifies the VolumeComponent this editor is drawing.

    Declaration
    public VolumeComponent target { get; }
    Property Value
    Type Description
    VolumeComponent

    Methods

    DrawOverrideCheckbox(SerializedDataParameter)

    Draws the override checkbox used by a property in the editor.

    Declaration
    protected void DrawOverrideCheckbox(SerializedDataParameter property)
    Parameters
    Type Name Description
    SerializedDataParameter property

    The property to draw the override checkbox for

    GetDisplayTitle()

    Sets the label for the component header. Override this method to provide a custom label. If you don't, Unity automatically inferres one from the class name.

    Declaration
    public virtual string GetDisplayTitle()
    Returns
    Type Description
    String

    A label to display in the component header.

    OnDisable()

    Unity calls this method when the object goes out of scope.

    Declaration
    public virtual void OnDisable()

    OnEnable()

    Unity calls this method when the object loads.

    Declaration
    public virtual void OnEnable()
    Remarks

    You can safely override this method and not call base.OnEnable() unless you want Unity to display all the properties from the VolumeComponent automatically.

    OnInspectorGUI()

    Unity calls this method everytime it re-draws the Inspector.

    Declaration
    public virtual void OnInspectorGUI()
    Remarks

    You can safely override this method and not call base.OnInspectorGUI() unless you want Unity to display all the properties from the VolumeComponent automatically.

    PropertyField(SerializedDataParameter)

    Draws a given SerializedDataParameter in the editor.

    Declaration
    protected void PropertyField(SerializedDataParameter property)
    Parameters
    Type Name Description
    SerializedDataParameter property

    The property to draw in the editor

    PropertyField(SerializedDataParameter, GUIContent)

    Draws a given SerializedDataParameter in the editor using a custom label and tooltip.

    Declaration
    protected void PropertyField(SerializedDataParameter property, GUIContent title)
    Parameters
    Type Name Description
    SerializedDataParameter property

    The property to draw in the editor.

    GUIContent title

    A custom label and/or tooltip.

    Repaint()

    Triggers an Inspector repaint event.

    Declaration
    public void Repaint()

    Unpack(SerializedProperty)

    Generates and auto-populates a SerializedDataParameter from a serialized VolumeParameter<T>.

    Declaration
    protected SerializedDataParameter Unpack(SerializedProperty property)
    Parameters
    Type Name Description
    SerializedProperty property

    A serialized property holding a VolumeParameter<T>

    Returns
    Type Description
    SerializedDataParameter

    See Also

    VolumeComponentEditorAttribute
    Back to top
    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