using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine.Rendering.PostProcessing;
namespace UnityEditor.Rendering.PostProcessing
{
///
/// A default effect editor that gathers all parameters and list them vertically in the
/// inspector.
///
public class DefaultPostProcessEffectEditor : PostProcessEffectBaseEditor
{
List m_Parameters;
///
/// Called when the editor is initialized.
///
public override void OnEnable()
{
m_Parameters = new List();
var fields = target.GetType()
.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.Where(t => t.FieldType.IsSubclassOf(typeof(ParameterOverride)) && t.Name != "enabled")
.Where(t =>
(t.IsPublic && t.GetCustomAttributes(typeof(NonSerializedAttribute), false).Length == 0)
|| (t.GetCustomAttributes(typeof(UnityEngine.SerializeField), false).Length > 0)
)
.ToList();
foreach (var field in fields)
{
var property = serializedObject.FindProperty(field.Name);
var attributes = field.GetCustomAttributes(false).Cast().ToArray();
var parameter = new SerializedParameterOverride(property, attributes);
m_Parameters.Add(parameter);
}
}
///
/// Called every time the inspector is being redrawn. This is where you should add your UI
/// drawing code.
///
public override void OnInspectorGUI()
{
foreach (var parameter in m_Parameters)
PropertyField(parameter);
}
}
}