Create SerializedPropertyExtensions and move method

This commit is contained in:
Makihiro 2024-02-18 02:39:33 +09:00
parent f656cd0f12
commit b8c11e7836
3 changed files with 45 additions and 23 deletions

View File

@ -1,34 +1,14 @@
#if UNITY_2019_3_OR_NEWER
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace MackySoft.SerializeReferenceExtensions.Editor {
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;

View File

@ -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

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b934aeca38cb7a24cabd6047fe0e298a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: