using System; using System.Linq.Expressions; namespace UnityEditor.Recorder { static class SerializableObjHelper { public static SerializedProperty FindPropertyRelative(this SerializedProperty obj, Expression> exp) { var body = exp.Body as MemberExpression; if (body == null) { var ubody = (UnaryExpression)exp.Body; body = ubody.Operand as MemberExpression; } var name = body.Member.Name; return obj.FindPropertyRelative(name); } } class PropertyFinder where TType : class { SerializedObject m_Obj; public PropertyFinder(SerializedObject obj) { m_Obj = obj; } public delegate TResult FuncX(TType x); public SerializedProperty Find( Expression> exp) { var body = exp.Body as MemberExpression; if (body == null) { var ubody = (UnaryExpression)exp.Body; body = ubody.Operand as MemberExpression; } var name = body.Member.Name; return m_Obj.FindProperty(name); } } }