From 56c9be6f8cd8724c28edec51d6ead44c1d0eb741 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 20 Jan 2023 01:55:09 -0600 Subject: [PATCH] fixes --- .../Editor/CustomEditors/Editors/TagEditor.cs | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Source/Editor/CustomEditors/Editors/TagEditor.cs b/Source/Editor/CustomEditors/Editors/TagEditor.cs index 9d538cbce..c6fd4a9a4 100644 --- a/Source/Editor/CustomEditors/Editors/TagEditor.cs +++ b/Source/Editor/CustomEditors/Editors/TagEditor.cs @@ -175,8 +175,6 @@ namespace FlaxEditor.CustomEditors.Editors { if (string.IsNullOrEmpty(subInputs[i])) { - lastTagString = tagString; - tagString = string.Empty; continue; } @@ -194,8 +192,6 @@ namespace FlaxEditor.CustomEditors.Editors if (Tags.List.Contains(tagString)) { - parentNode = tree.GetChild(); // return to root - parentCount = 0; // Find next parent node foreach (var child in parentNode.Children) { @@ -213,11 +209,27 @@ namespace FlaxEditor.CustomEditors.Editors tagString = string.Empty; continue; } + else if (subInputs.Length > 1) + { + // Find next parent node + foreach (var child in parentNode.Children) + { + if (!(child is TreeNode childNode)) + continue; + + var tagValue = (Tag)childNode.Tag; + if (!string.Equals(tagValue.ToString(), lastTagString)) + continue; + + parentNode = childNode; + parentCount += 1; + } + } // Create new node var nodeIndent = 16.0f; var indentation = 0; - var parentTag = lastTagString; + var parentTag = string.Empty; if (parentNode.CustomArrowRect.HasValue) { indentation = (int)((parentNode.CustomArrowRect.Value.Location.X - 18) / nodeIndent) + 1; @@ -282,18 +294,17 @@ namespace FlaxEditor.CustomEditors.Editors // Update asset var settingsObj = (LayersAndTagsSettings)settingsAsset.Instance; settingsObj.Tags.Add(tagName); + settingsObj.Tags.Sort(); settingsAsset.SetInstance(settingsObj); // Reload editor window to reflect new tag assetWindow?.RefreshAsset(); - assetWindow?.MarkAsEdited(); - assetWindow?.Save(); } - textBox.Text = string.Empty; lastTagString = tagString; tagString = string.Empty; } + textBox.Text = string.Empty; } private static void OnAddSubTagButtonClicked(string parentTag, TextBox textBox, DropPanel dropPanel)