Create SerializedPropertyExtensions and move method
This commit is contained in:
parent
f656cd0f12
commit
b8c11e7836
@ -1,34 +1,14 @@
|
|||||||
#if UNITY_2019_3_OR_NEWER
|
#if UNITY_2019_3_OR_NEWER
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace MackySoft.SerializeReferenceExtensions.Editor {
|
namespace MackySoft.SerializeReferenceExtensions.Editor
|
||||||
|
{
|
||||||
|
|
||||||
public static class ManagedReferenceUtility {
|
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) {
|
public static object SetManagedReference (this SerializedProperty property,Type type) {
|
||||||
object result = null;
|
object result = null;
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
#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
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b934aeca38cb7a24cabd6047fe0e298a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user