From b8c11e7836e4563f89df411ae12e939fbc23b2bc Mon Sep 17 00:00:00 2001 From: Makihiro Date: Sun, 18 Feb 2024 02:39:33 +0900 Subject: [PATCH] Create SerializedPropertyExtensions and move method --- .../Editor/ManagedReferenceUtility.cs | 26 ++-------------- .../Editor/SerializedPropertyExtensions.cs | 31 +++++++++++++++++++ .../SerializedPropertyExtensions.cs.meta | 11 +++++++ 3 files changed, 45 insertions(+), 23 deletions(-) create mode 100644 Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SerializedPropertyExtensions.cs create mode 100644 Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SerializedPropertyExtensions.cs.meta diff --git a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs index bb07026..0d84906 100644 --- a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs +++ b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs @@ -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 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; diff --git a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SerializedPropertyExtensions.cs b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SerializedPropertyExtensions.cs new file mode 100644 index 0000000..135fe25 --- /dev/null +++ b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SerializedPropertyExtensions.cs @@ -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 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 \ No newline at end of file diff --git a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SerializedPropertyExtensions.cs.meta b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SerializedPropertyExtensions.cs.meta new file mode 100644 index 0000000..0491dc7 --- /dev/null +++ b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SerializedPropertyExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b934aeca38cb7a24cabd6047fe0e298a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: