You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
697 B
31 lines
697 B
#if UNITY_2019_3_OR_NEWER
|
|
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
|
|
namespace MackySoft.SerializeReferenceExtensions.Editor
|
|
{
|
|
public static class SerializedPropertyExtensions
|
|
{
|
|
public static IEnumerable<SerializedProperty> 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();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif
|