Fix prefab diff context menu in Editor to properly diff against arrays

This commit is contained in:
Wojtek Figat
2023-06-11 20:44:04 +02:00
parent 958c7b2181
commit 31c9b85a3f
2 changed files with 5 additions and 8 deletions

View File

@@ -218,7 +218,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
node.Text = Utilities.Utils.GetPropertyNameUI(sceneObject.GetType().Name);
}
// Array Item
else if (editor.ParentEditor?.Values?.Type.IsArray ?? false)
else if (editor.ParentEditor is CollectionEditor)
{
node.Text = "Element " + editor.ParentEditor.ChildrenEditors.IndexOf(editor);
}
@@ -261,16 +261,14 @@ namespace FlaxEditor.CustomEditors.Dedicated
}
// Skip if no change detected
if (!editor.Values.IsReferenceValueModified && skipIfNotModified)
var isRefEdited = editor.Values.IsReferenceValueModified;
if (!isRefEdited && skipIfNotModified)
return null;
TreeNode result = null;
if (editor.ChildrenEditors.Count == 0)
if (editor.ChildrenEditors.Count == 0 || (isRefEdited && editor is CollectionEditor))
result = CreateDiffNode(editor);
bool isScriptEditorWithRefValue = editor is ScriptsEditor && editor.Values.HasReferenceValue;
for (int i = 0; i < editor.ChildrenEditors.Count; i++)
{
var child = ProcessDiff(editor.ChildrenEditors[i], !isScriptEditorWithRefValue);
@@ -278,7 +276,6 @@ namespace FlaxEditor.CustomEditors.Dedicated
{
if (result == null)
result = CreateDiffNode(editor);
result.AddChild(child);
}
}