fix ResetValues for SerializedProperty

This commit is contained in:
Mikhail 2024-09-15 00:00:32 +08:00
parent a0f5129f3e
commit c12fe06b2d

View File

@ -117,6 +117,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
private static Dictionary<Type, MonoScript> scriptsAssets = new Dictionary<Type, MonoScript>(256); private static Dictionary<Type, MonoScript> scriptsAssets = new Dictionary<Type, MonoScript>(256);
internal static void ResetValues(this SerializedProperty property, bool isExpand = false) internal static void ResetValues(this SerializedProperty property, bool isExpand = false)
{
ResetValues_Internal(property.Copy(), isExpand, property.depth);
}
private static void ResetValues_Internal(SerializedProperty property, bool isExpand, int depth)
{ {
property.isExpanded = isExpand; property.isExpanded = isExpand;
switch (property.propertyType) switch (property.propertyType)
@ -127,9 +131,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
//InvalidOperationException: The operation is not possible when moved past all properties (Next returned false) //InvalidOperationException: The operation is not possible when moved past all properties (Next returned false)
//и не дает инструментов и шансов этого избежать //и не дает инструментов и шансов этого избежать
{ {
while (property.Next(true)) bool x = true;
while (property.Next(x) && property.depth > depth)
{ {
property.ResetValues(isExpand); ResetValues_Internal(property, isExpand, property.depth);
x = false;
} }
} }
catch (Exception) { } catch (Exception) { }