Add GetChildProperties
This commit is contained in:
parent
f69bfc6773
commit
f656cd0f12
@ -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<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();
|
||||
}
|
||||
}
|
||||
|
||||
public static object SetManagedReference (this SerializedProperty property,Type type) {
|
||||
object result = null;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user