diff --git a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs index b071f71..bb07026 100644 --- a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs +++ b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs @@ -1,5 +1,6 @@ #if UNITY_2019_3_OR_NEWER using System; +using System.Collections.Generic; using System.Reflection; using UnityEditor; using UnityEngine; @@ -7,6 +8,27 @@ using UnityEngine; namespace MackySoft.SerializeReferenceExtensions.Editor { public static class ManagedReferenceUtility { + public static IEnumerable GetChildProperties (this SerializedProperty parent, int depth = 1) + { + parent = parent.Copy(); + + int depthOfParent = parent.depth; + var enumerator = parent.GetEnumerator(); + + while (enumerator.MoveNext()) + { + if (enumerator.Current is not SerializedProperty childProperty) + { + continue; + } + if (childProperty.depth > (depthOfParent + depth)) + { + continue; + } + yield return childProperty.Copy(); + } + } + public static object SetManagedReference (this SerializedProperty property,Type type) { object result = null;