using System; using System.Linq.Expressions; using UnityEngine; using UnityEngine.Rendering.PostProcessing; namespace UnityEditor.Rendering.PostProcessing { /// /// Small wrapper on top of to ease the access of the underlying component /// and its serialized fields. /// /// The type of the target component to make an editor for /// /// /// 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); /// } /// } /// /// public class BaseEditor : Editor where T : MonoBehaviour { /// /// The target component. /// protected T m_Target { get { return (T)target; } } /// /// /// /// /// /// protected SerializedProperty FindProperty(Expression> expr) { return serializedObject.FindProperty(RuntimeUtilities.GetFieldPath(expr)); } } }