/// To use with extreme caution. It not really get the property but try to find a field with similar name /// Hence inheritance override of property is not supported. /// Also variable rename will silently break the search. /// <summary> /// Find a property based on an expression. /// </summary> /// <typeparam name="TValue">Type of the serialized object.</typeparam> /// <param name="expr">Expression for the property.</param> /// <returns>Required property if it exists, null otherwise.</returns> public SerializedProperty Find <TValue>(Expression <Func <T, TValue> > expr) { string path = CoreEditorUtils.FindProperty(expr); return(obj.FindProperty(path)); }
/// <summary> /// /// </summary> /// <typeparam name="TSource"></typeparam> /// <typeparam name="TValue"></typeparam> /// <param name="obj"></param> /// <param name="expr"></param> /// <returns></returns> public static SerializedProperty Find <TSource, TValue>(this SerializedProperty obj, Expression <Func <TSource, TValue> > expr) { var path = CoreEditorUtils.FindProperty(expr); return(obj.FindPropertyRelative(path)); }