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 CustomEditor to let the editor know which component this drawer is for.
Inherited Members
Namespace: UnityEditor.Rendering
Assembly: Unity.RenderPipelines.Core.Editor.dll
Syntax
[CustomEditor(typeof(VolumeComponent), true)]
public class VolumeComponentEditor : Editor
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;
[CustomEditor(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
Name | Description |
---|---|
m_Inspector | A reference to the parent editor in the Inspector. |
Properties
Name | Description |
---|---|
activeProperty | The serialized property of active for the component being inspected. |
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. |
expanded | If the editor for this VolumeComponent is expanded or not in the inspector |
hasAdditionalProperties | Override this property if your editor makes use of the "Additional Properties" feature. |
showAdditionalProperties | Set to true to show additional properties. |
volume | Obtains the Volume that is being edited from this volume component |
volumeComponent | Specifies the VolumeComponent this editor is drawing. |
Methods
Name | Description |
---|---|
BeginAdditionalPropertiesScope() | Start a scope for additional properties. This will handle the highlight of the background when toggled on and off. |
DrawHeader(string) | Draws a header into the inspector with the given title |
DrawOverrideCheckbox(SerializedDataParameter) | Draws the override checkbox used by a property in the editor. |
EndAdditionalPropertiesScope() | End a scope for additional properties. |
GetDisplayTitle() | Sets the label for the component header. Override this method to provide a custom label. If you don't, Unity automatically obtains one from the class name. |
OnDisable() | Unity calls this method when the object goes out of scope. |
OnEnable() | Unity calls this method when the object loads. |
OnInspectorGUI() | Unity calls this method each time it re-draws the Inspector. |
PropertyField(SerializedDataParameter) | Draws a given SerializedDataParameter in the editor. |
PropertyField(SerializedDataParameter, GUIContent) | Draws a given SerializedDataParameter in the editor using a custom label and tooltip. |
Repaint() | Triggers an Inspector repaint event. |
Unpack(SerializedProperty) | Generates and auto-populates a SerializedDataParameter from a serialized VolumeParameter<T>. |