Skip to content

Commit b8c11e7

Browse files
committed
Create SerializedPropertyExtensions and move method
1 parent f656cd0 commit b8c11e7

File tree

3 files changed

+45
-23
lines changed

3 files changed

+45
-23
lines changed

Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/ManagedReferenceUtility.cs

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
11
#if UNITY_2019_3_OR_NEWER
22
using System;
3-
using System.Collections.Generic;
43
using System.Reflection;
54
using UnityEditor;
65
using UnityEngine;
76

8-
namespace MackySoft.SerializeReferenceExtensions.Editor {
9-
public static class ManagedReferenceUtility {
10-
11-
public static IEnumerable<SerializedProperty> GetChildProperties (this SerializedProperty parent, int depth = 1)
12-
{
13-
parent = parent.Copy();
7+
namespace MackySoft.SerializeReferenceExtensions.Editor
8+
{
149

15-
int depthOfParent = parent.depth;
16-
var enumerator = parent.GetEnumerator();
17-
18-
while (enumerator.MoveNext())
19-
{
20-
if (enumerator.Current is not SerializedProperty childProperty)
21-
{
22-
continue;
23-
}
24-
if (childProperty.depth > (depthOfParent + depth))
25-
{
26-
continue;
27-
}
28-
yield return childProperty.Copy();
29-
}
30-
}
10+
public static class ManagedReferenceUtility {
3111

3212
public static object SetManagedReference (this SerializedProperty property,Type type) {
3313
object result = null;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#if UNITY_2019_3_OR_NEWER
2+
using System.Collections.Generic;
3+
using UnityEditor;
4+
5+
namespace MackySoft.SerializeReferenceExtensions.Editor
6+
{
7+
public static class SerializedPropertyExtensions
8+
{
9+
public static IEnumerable<SerializedProperty> GetChildProperties (this SerializedProperty parent, int depth = 1)
10+
{
11+
parent = parent.Copy();
12+
13+
int depthOfParent = parent.depth;
14+
var enumerator = parent.GetEnumerator();
15+
16+
while (enumerator.MoveNext())
17+
{
18+
if (enumerator.Current is not SerializedProperty childProperty)
19+
{
20+
continue;
21+
}
22+
if (childProperty.depth > (depthOfParent + depth))
23+
{
24+
continue;
25+
}
26+
yield return childProperty.Copy();
27+
}
28+
}
29+
}
30+
}
31+
#endif

Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SerializedPropertyExtensions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)