Skip to content

Commit 04b639a

Browse files
committed
Fixed the nested value does not update.
1 parent 60725fd commit 04b639a

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

Assets/Script Tester/Editor/InspectorDrawer.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,23 @@ public void Draw(bool drawHeader = true, bool readOnly = false) {
104104
EditorGUI.indentLevel--;
105105
}
106106

107+
public void UpdateValues(bool updateProps) {
108+
foreach (var drawerItem in drawer) {
109+
var propDrawer = drawerItem as MethodPropertyDrawer;
110+
if (propDrawer == null)
111+
continue;
112+
var isPropInfo = propDrawer.Info is PropertyInfo;
113+
if (!isInternalType && (!updateProps || !propDrawer.Updatable) && isPropInfo)
114+
continue;
115+
object value;
116+
if (Helper.FetchValue(propDrawer.Info, target, out value)) {
117+
propDrawer.Value = value;
118+
propDrawer.GetException = null;
119+
} else
120+
propDrawer.GetException = value as Exception;
121+
}
122+
}
123+
107124
void RequireRedraw() {
108125
if (OnRequireRedraw != null)
109126
OnRequireRedraw();

Assets/Script Tester/Editor/InspectorPlus.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,7 @@ void UpdateValues() {
176176

177177
void UpdateValues(bool updateProps) {
178178
foreach (var drawerGroup in drawers.SelectMany(drawer => drawer))
179-
foreach (var drawerItem in drawerGroup.drawer) {
180-
var propDrawer = drawerItem as MethodPropertyDrawer;
181-
if (propDrawer == null)
182-
continue;
183-
var isPropInfo = propDrawer.Info is PropertyInfo;
184-
if (!drawerGroup.isInternalType && (!updateProps || !propDrawer.Updatable) && isPropInfo)
185-
continue;
186-
object value;
187-
if(Helper.FetchValue(propDrawer.Info, drawerGroup.target, out value)) {
188-
propDrawer.Value = value;
189-
propDrawer.GetException = null;
190-
} else
191-
propDrawer.GetException = value as Exception;
192-
}
179+
drawerGroup.UpdateValues(updateProps);
193180
Repaint();
194181
}
195182
}

Assets/Script Tester/Editor/MethodPropertyDrawer.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ public object Value {
185185
rawValue = value;
186186
changed = false;
187187
SetArray();
188+
if (unknownTypeDrawer != null) {
189+
if (unknownTypeDrawer.target != value)
190+
unknownTypeDrawer = null;
191+
else
192+
unknownTypeDrawer.UpdateValues(true);
193+
}
188194
}
189195
}
190196

@@ -540,6 +546,7 @@ void DrawUnknownField(bool readOnly, object target) {
540546
} else if (unknownTypeDrawer == null || unknownTypeDrawer.target != target) {
541547
unknownTypeDrawer = new InspectorDrawer(target, true, true, privateFields, obsolete, true);
542548
unknownTypeDrawer.OnRequireRedraw += RequireRedraw;
549+
unknownTypeDrawer.UpdateValues(true);
543550
}
544551
if (unknownTypeDrawer != null) {
545552
unknownTypeDrawer.shown = true;

0 commit comments

Comments
 (0)