Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit ddb0b87

Browse files
Fixed iterator not handling vectors properly
1 parent 7000b15 commit ddb0b87

3 files changed

Lines changed: 22 additions & 38 deletions

File tree

Assets/SO Architecture/Editor/Drawers/GenericPropertyDrawer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using UnityEditor;
34
using UnityEngine;
45
using Object = UnityEngine.Object;

Assets/SO Architecture/Editor/Generic Property Drawer/PropertyIterator.cs

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ public class PropertyIterator : IPropertyIterator
99
{
1010
public PropertyIterator(SerializedProperty property)
1111
{
12-
iterator = property;
13-
Next();
14-
12+
iterator = property.Copy();
1513
endProperty = iterator.GetEndProperty();
1614
}
1715

@@ -23,44 +21,33 @@ public PropertyIterator(SerializedProperty property)
2321

2422
public virtual bool Next()
2523
{
26-
bool nextVisible = iterator.NextVisible(true);
27-
bool canDraw = CanDraw();
28-
29-
if (nextVisible)
24+
bool nextVisible = false;
25+
if(IsSingleLine(iterator))
3026
{
31-
if (IsScriptField(iterator))
32-
nextVisible = NextVisible();
33-
34-
if (consumeChildren)
35-
{
36-
ConsumeSingleLineFields(parentDepth);
37-
consumeChildren = false;
38-
}
39-
40-
int depth = iterator.depth;
41-
if (IsSingleLine(iterator))
42-
{
43-
parentDepth = depth;
44-
consumeChildren = true;
45-
}
27+
parentDepth = iterator.depth;
28+
nextVisible = iterator.NextVisible(false);
4629
}
47-
48-
return nextVisible && canDraw;
30+
else
31+
{
32+
nextVisible = iterator.NextVisible(true);
33+
}
34+
35+
return nextVisible && CanDraw();
4936
}
5037
public virtual void End()
5138
{
5239
}
53-
private bool CanDraw()
54-
{
55-
return !SerializedProperty.EqualContents(iterator, endProperty);
56-
}
57-
private void ConsumeSingleLineFields(int depth)
40+
private void UpdateState(SerializedProperty property)
5841
{
59-
do
42+
if (IsSingleLine(iterator))
6043
{
61-
iterator.Next(true);
44+
parentDepth = iterator.depth;
45+
consumeChildren = true;
6246
}
63-
while (iterator.depth != depth);
47+
}
48+
private bool CanDraw()
49+
{
50+
return !SerializedProperty.EqualContents(iterator, endProperty);
6451
}
6552
private bool IsSingleLine(SerializedProperty property)
6653
{
@@ -81,10 +68,6 @@ private bool IsSingleLine(SerializedProperty property)
8168

8269
return false;
8370
}
84-
private bool IsScriptField(SerializedProperty property)
85-
{
86-
return property.propertyPath == "m_Script";
87-
}
8871
private bool NextVisible()
8972
{
9073
return iterator.NextVisible(true);

Assets/SO Architecture/Editor/Inspectors/BaseVariableEditor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public override void OnInspectorGUI()
4747
}
4848
protected virtual void DrawValue()
4949
{
50-
//GenericPropertyDrawer.DrawPropertyDrawerLayoutNew(_valueProperty, Target.Type);
51-
GenericPropertyDrawer.DrawPropertyDrawerLayoutNew(serializedObject.GetIterator(), Target.Type);
50+
GenericPropertyDrawer.DrawPropertyDrawerLayoutNew(_valueProperty, Target.Type);
51+
//GenericPropertyDrawer.DrawPropertyDrawerLayoutNew(serializedObject.GetIterator(), Target.Type);
5252

5353
EditorGUILayout.Space();
5454

0 commit comments

Comments
 (0)