From 436697601599bb3a3ba20ef4b918c38731819fb3 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 23 May 2025 13:27:01 -0500 Subject: [PATCH 1/3] Add better prefab diff viewing naming for actors --- .../CustomEditors/Dedicated/ActorEditor.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs b/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs index 062aeeedd..8c238c060 100644 --- a/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs @@ -257,8 +257,17 @@ namespace FlaxEditor.CustomEditors.Dedicated // Actor or Script else if (editor.Values[0] is SceneObject sceneObject) { - node.TextColor = sceneObject.HasPrefabLink ? FlaxEngine.GUI.Style.Current.ProgressNormal : FlaxEngine.GUI.Style.Current.BackgroundSelected; - node.Text = Utilities.Utils.GetPropertyNameUI(sceneObject.GetType().Name); + if (editor.Values.Info != ScriptMemberInfo.Null) + { + if (editor.Values.GetAttributes().FirstOrDefault(x => x is EditorDisplayAttribute) is EditorDisplayAttribute editorDisplayAttribute && !string.IsNullOrEmpty(editorDisplayAttribute.Name)) + node.Text = $"{Utilities.Utils.GetPropertyNameUI(editorDisplayAttribute.Name)} ({Utilities.Utils.GetPropertyNameUI(editor.Values.Info.Name)})"; + else + node.Text = $"{Utilities.Utils.GetPropertyNameUI(editor.Values.Info.Name)}"; + } + else if (sceneObject is Actor actor) + node.Text = $"{actor.Name} ({Utilities.Utils.GetPropertyNameUI(sceneObject.GetType().Name)})"; + else + node.Text = Utilities.Utils.GetPropertyNameUI(sceneObject.GetType().Name); } // Array Item else if (editor.ParentEditor is CollectionEditor) @@ -268,7 +277,12 @@ namespace FlaxEditor.CustomEditors.Dedicated // Common type else if (editor.Values.Info != ScriptMemberInfo.Null) { - node.Text = Utilities.Utils.GetPropertyNameUI(editor.Values.Info.Name); + if (editor.Values.GetAttributes().FirstOrDefault(x => x is EditorDisplayAttribute) is EditorDisplayAttribute editorDisplayAttribute + && !string.IsNullOrEmpty(editorDisplayAttribute.Name) + && !editorDisplayAttribute.Name.Contains("_inline")) + node.Text = $"{Utilities.Utils.GetPropertyNameUI(editorDisplayAttribute.Name)} ({Utilities.Utils.GetPropertyNameUI(editor.Values.Info.Name)})"; + else + node.Text = Utilities.Utils.GetPropertyNameUI(editor.Values.Info.Name); } // Custom type else if (editor.Values[0] != null) From ae9622d271277a07c1c78c9e7519f54d02d0e7f8 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 23 May 2025 13:29:05 -0500 Subject: [PATCH 2/3] Re-add colors back in for nodes. --- Source/Editor/CustomEditors/Dedicated/ActorEditor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs b/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs index 8c238c060..77619712f 100644 --- a/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs @@ -257,6 +257,7 @@ namespace FlaxEditor.CustomEditors.Dedicated // Actor or Script else if (editor.Values[0] is SceneObject sceneObject) { + node.TextColor = sceneObject.HasPrefabLink ? FlaxEngine.GUI.Style.Current.ProgressNormal : FlaxEngine.GUI.Style.Current.BackgroundSelected; if (editor.Values.Info != ScriptMemberInfo.Null) { if (editor.Values.GetAttributes().FirstOrDefault(x => x is EditorDisplayAttribute) is EditorDisplayAttribute editorDisplayAttribute && !string.IsNullOrEmpty(editorDisplayAttribute.Name)) From e606c35093272ec121fa518bb989d9c44ada11e2 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 23 May 2025 16:23:22 -0500 Subject: [PATCH 3/3] Add node tree to show changes to whole prefab. --- .../CustomEditors/Dedicated/ActorEditor.cs | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs b/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs index 77619712f..3830ef14a 100644 --- a/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs @@ -376,20 +376,46 @@ namespace FlaxEditor.CustomEditors.Dedicated return result; } + private TreeNode CreateDiffTree(Actor actor, CustomEditorPresenter presenter, LayoutElementsContainer layout) + { + var actorNode = Editor.Instance.Scene.GetActorNode(actor); + ValueContainer vc = new ValueContainer(ScriptMemberInfo.Null); + vc.SetType(new ScriptType(actorNode.EditableObject.GetType())); + vc.Add(actorNode.EditableObject); + var editor = CustomEditorsUtil.CreateEditor(vc, null, false); + editor.Initialize(presenter, layout, vc); + var node = ProcessDiff(editor, false); + layout.ClearLayout(); + foreach (var child in actor.Children) + { + var childNode = CreateDiffTree(child, presenter, layout); + if (childNode == null) + continue; + if (node == null) + node = CreateDiffNode(editor); + node.AddChild(childNode); + } + return node; + } + private void ViewChanges(Control target, Float2 targetLocation) { // Build a tree out of modified properties - var rootNode = ProcessDiff(this, false); - + var thisActor = (Actor)Values[0]; + var rootActor = thisActor.IsPrefabRoot ? thisActor : thisActor.GetPrefabRoot(); + var presenter = new CustomEditorPresenter(null); + var layout = new CustomElementsContainer(); + var rootNode = CreateDiffTree(rootActor, presenter, layout); + // Skip if no changes detected - if (rootNode == null || rootNode.ChildrenCount == 0) + if (rootNode == null) { var cm1 = new ContextMenu(); cm1.AddButton("No changes detected"); cm1.Show(target, targetLocation); return; } - + // Create context menu var cm = new PrefabDiffContextMenu(); cm.Tree.AddChild(rootNode);