Class BaseEditor<T>
Small wrapper on top of Editor to ease the access of the underlying component and its serialized fields.
Inherited Members
Editor.MoveNextTarget()
Namespace: UnityEditor.Rendering.PostProcessing
Assembly: Unity.Postprocessing.Editor.dll
Syntax
public class BaseEditor<T> : Editor where T : MonoBehaviour
Type Parameters
| Name | Description |
|---|---|
| T | The type of the target component to make an editor for |
Examples
public class MyMonoBehaviour : MonoBehaviour
{
public float myProperty = 1.0f;
}
[CustomEditor(typeof(MyMonoBehaviour))]
public sealed class MyMonoBehaviourEditor : BaseEditor<MyMonoBehaviour>
{
SerializedProperty m_MyProperty;
void OnEnable()
{
m_MyProperty = FindProperty(x => x.myProperty);
}
public override void OnInspectorGUI()
{
EditorGUILayout.PropertyField(m_MyProperty);
}
}
Properties
m_Target
The target component.
Declaration
protected T m_Target { get; }
Property Value
| Type | Description |
|---|---|
| T |
Methods
FindProperty<TValue>(Expression<Func<T, TValue>>)
Find a serialized property using an expression instead of a string. This is safer as it helps avoiding typos and make code refactoring easier.
Declaration
protected SerializedProperty FindProperty<TValue>(Expression<Func<T, TValue>> expr)
Parameters
| Type | Name | Description |
|---|---|---|
| Expression<Func<T, TValue>> | expr | The expression to parse to reach the property |
Returns
| Type | Description |
|---|---|
| SerializedProperty | A SerializedProperty or |
Type Parameters
| Name | Description |
|---|---|
| TValue | The serialized value type |