From e568e6e17b49213108c668f0aaee1d23e94ee9d1 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Thu, 1 May 2025 19:15:43 +0200 Subject: [PATCH 1/2] improve import path ui --- .../Dedicated/ModelPrefabEditor.cs | 3 ++- Source/Editor/Utilities/Utils.cs | 20 +++++++++---------- .../Editor/Windows/Assets/AnimationWindow.cs | 3 ++- .../Editor/Windows/Assets/AudioClipWindow.cs | 7 +++++-- .../Windows/Assets/CubeTextureWindow.cs | 7 ++++--- .../Editor/Windows/Assets/ModelBaseWindow.cs | 11 +++++----- .../Windows/Assets/SpriteAtlasWindow.cs | 5 +++-- Source/Editor/Windows/Assets/TextureWindow.cs | 3 ++- 8 files changed, 33 insertions(+), 26 deletions(-) diff --git a/Source/Editor/CustomEditors/Dedicated/ModelPrefabEditor.cs b/Source/Editor/CustomEditors/Dedicated/ModelPrefabEditor.cs index 65b39962b..f57548258 100644 --- a/Source/Editor/CustomEditors/Dedicated/ModelPrefabEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/ModelPrefabEditor.cs @@ -54,7 +54,8 @@ public class ModelPrefabEditor : GenericEditor } // Creates the import path UI - Utilities.Utils.CreateImportPathUI(layout, modelPrefab.ImportPath, false); + var group = layout.Group("Import Path"); + Utilities.Utils.CreateImportPathUI(group, modelPrefab.ImportPath, false); var button = layout.Button("Reimport", "Reimports the source asset as prefab."); _reimportButton = button.Button; diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs index b4666b213..ad2ee87a2 100644 --- a/Source/Editor/Utilities/Utils.cs +++ b/Source/Editor/Utilities/Utils.cs @@ -402,33 +402,31 @@ namespace FlaxEditor.Utilities /// /// Creates an Import path ui that show the asset import path and adds a button to show the folder in the file system. /// - /// The parent layout container. + /// The parent group element. /// The asset item to get the import path of. - public static void CreateImportPathUI(CustomEditors.LayoutElementsContainer parentLayout, Content.BinaryAssetItem assetItem) + public static void CreateImportPathUI(CustomEditors.Elements.GroupElement group, Content.BinaryAssetItem assetItem) { assetItem.GetImportPath(out var path); - CreateImportPathUI(parentLayout, path); + CreateImportPathUI(group, path); } /// /// Creates an Import path ui that show the import path and adds a button to show the folder in the file system. /// - /// The parent layout container. + /// The parent group element. /// The import path. /// Whether to use an initial layout space of 5 for separation. - public static void CreateImportPathUI(CustomEditors.LayoutElementsContainer parentLayout, string path, bool useInitialSpacing = true) + public static void CreateImportPathUI(CustomEditors.Elements.GroupElement group, string path, bool useInitialSpacing = true) { if (!string.IsNullOrEmpty(path)) { if (useInitialSpacing) - parentLayout.Space(5); - parentLayout.Label("Import Path:").Label.TooltipText = "Source asset path (can be relative or absolute to the project)"; - var textBox = parentLayout.TextBox().TextBox; - textBox.TooltipText = "Path is not editable here."; + group.Space(0); + var textBox = group.TextBox().TextBox; + textBox.TooltipText = "Source asset path. Can be relative or absolute to the project. Path is not editable here."; textBox.IsReadOnly = true; textBox.Text = path; - parentLayout.Space(2); - var button = parentLayout.Button(Constants.ShowInExplorer).Button; + var button = group.Button(Constants.ShowInExplorer).Button; button.Clicked += () => FileSystem.ShowFileExplorer(Path.GetDirectoryName(path)); } } diff --git a/Source/Editor/Windows/Assets/AnimationWindow.cs b/Source/Editor/Windows/Assets/AnimationWindow.cs index 1235bf62d..41fdfde65 100644 --- a/Source/Editor/Windows/Assets/AnimationWindow.cs +++ b/Source/Editor/Windows/Assets/AnimationWindow.cs @@ -231,7 +231,8 @@ namespace FlaxEditor.Windows.Assets group.Object(importSettingsValues); // Creates the import path UI - Utilities.Utils.CreateImportPathUI(layout, proxy.Window.Item as BinaryAssetItem); + group = layout.Group("Import Path"); + Utilities.Utils.CreateImportPathUI(group, proxy.Window.Item as BinaryAssetItem); layout.Space(5); var reimportButton = layout.Button("Reimport"); diff --git a/Source/Editor/Windows/Assets/AudioClipWindow.cs b/Source/Editor/Windows/Assets/AudioClipWindow.cs index 1c15ee96f..250a7eb77 100644 --- a/Source/Editor/Windows/Assets/AudioClipWindow.cs +++ b/Source/Editor/Windows/Assets/AudioClipWindow.cs @@ -6,6 +6,7 @@ using FlaxEditor.Content.Import; using FlaxEditor.CustomEditors; using FlaxEditor.CustomEditors.Editors; using FlaxEditor.GUI; +using FlaxEditor.Scripting; using FlaxEditor.Viewport.Previews; using FlaxEngine; using FlaxEngine.GUI; @@ -76,7 +77,8 @@ namespace FlaxEditor.Windows.Assets { public override void Initialize(LayoutElementsContainer layout) { - var window = ((PropertiesProxy)Values[0])._window; + var proxy = ((PropertiesProxy)Values[0]); + var window = proxy._window; if (window == null) { layout.Label("Loading...", TextAlignment.Center); @@ -101,7 +103,8 @@ namespace FlaxEditor.Windows.Assets base.Initialize(layout); // Creates the import path UI - Utilities.Utils.CreateImportPathUI(layout, window.Item as BinaryAssetItem); + var pathGroup = layout.Group("Import Path"); + Utilities.Utils.CreateImportPathUI(pathGroup, window.Item as BinaryAssetItem); layout.Space(5); var reimportButton = layout.Button("Reimport"); diff --git a/Source/Editor/Windows/Assets/CubeTextureWindow.cs b/Source/Editor/Windows/Assets/CubeTextureWindow.cs index c27061630..c4d7ab053 100644 --- a/Source/Editor/Windows/Assets/CubeTextureWindow.cs +++ b/Source/Editor/Windows/Assets/CubeTextureWindow.cs @@ -55,10 +55,11 @@ namespace FlaxEditor.Windows.Assets base.Initialize(layout); // Creates the import path UI - Utilities.Utils.CreateImportPathUI(layout, window.Item as BinaryAssetItem); + var pathGroup = layout.Group("Import Path"); + Utilities.Utils.CreateImportPathUI(pathGroup, window.Item as BinaryAssetItem); - layout.Space(5); - var reimportButton = layout.Button("Reimport"); + pathGroup.Space(5); + var reimportButton = pathGroup.Button("Reimport"); reimportButton.Button.Clicked += () => ((PropertiesProxy)Values[0]).Reimport(); } } diff --git a/Source/Editor/Windows/Assets/ModelBaseWindow.cs b/Source/Editor/Windows/Assets/ModelBaseWindow.cs index 3431dfd7f..216dede67 100644 --- a/Source/Editor/Windows/Assets/ModelBaseWindow.cs +++ b/Source/Editor/Windows/Assets/ModelBaseWindow.cs @@ -754,17 +754,18 @@ namespace FlaxEditor.Windows.Assets if (Utilities.Utils.OnAssetProperties(layout, proxy.Asset)) return; - var group = layout.Group("Import Settings"); + var importSettingsGroup = layout.Group("Import Settings"); var importSettingsField = typeof(ImportPropertiesProxyBase).GetField(nameof(ImportSettings), BindingFlags.NonPublic | BindingFlags.Instance); var importSettingsValues = new ValueContainer(new ScriptMemberInfo(importSettingsField)) { proxy.ImportSettings }; - group.Object(importSettingsValues); + importSettingsGroup.Object(importSettingsValues); + importSettingsGroup.Space(3); // Creates the import path UI - Utilities.Utils.CreateImportPathUI(layout, proxy.Window.Item as BinaryAssetItem); + var group = layout.Group("Import Path"); + Utilities.Utils.CreateImportPathUI(group, proxy.Window.Item as BinaryAssetItem); - layout.Space(5); - var reimportButton = group.Button("Reimport"); + var reimportButton = importSettingsGroup.Button("Reimport"); reimportButton.Button.Clicked += () => ((ImportPropertiesProxyBase)Values[0]).Reimport(); } } diff --git a/Source/Editor/Windows/Assets/SpriteAtlasWindow.cs b/Source/Editor/Windows/Assets/SpriteAtlasWindow.cs index 44016e57a..94deb18c0 100644 --- a/Source/Editor/Windows/Assets/SpriteAtlasWindow.cs +++ b/Source/Editor/Windows/Assets/SpriteAtlasWindow.cs @@ -119,9 +119,10 @@ namespace FlaxEditor.Windows.Assets } base.Initialize(layout); - + // Creates the import path UI - Utilities.Utils.CreateImportPathUI(layout, proxy._window.Item as BinaryAssetItem); + var group = layout.Group("Import Path"); + Utilities.Utils.CreateImportPathUI(group, proxy._window.Item as BinaryAssetItem); layout.Space(5); var reimportButton = layout.Button("Reimport"); diff --git a/Source/Editor/Windows/Assets/TextureWindow.cs b/Source/Editor/Windows/Assets/TextureWindow.cs index 06c6120ad..865099aea 100644 --- a/Source/Editor/Windows/Assets/TextureWindow.cs +++ b/Source/Editor/Windows/Assets/TextureWindow.cs @@ -143,7 +143,8 @@ namespace FlaxEditor.Windows.Assets base.Initialize(layout); // Creates the import path UI - Utilities.Utils.CreateImportPathUI(layout, proxy._window.Item as BinaryAssetItem); + var group = layout.Group("Import Path"); + Utilities.Utils.CreateImportPathUI(group, proxy._window.Item as BinaryAssetItem); // Reimport layout.Space(5); From f5ad8566ebf22d48805cd643f29fe766d60a7121 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Fri, 2 May 2025 13:29:01 +0200 Subject: [PATCH 2/2] make path creation method more generalized --- Source/Editor/Utilities/Utils.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs index ad2ee87a2..7c7d3d2d2 100644 --- a/Source/Editor/Utilities/Utils.cs +++ b/Source/Editor/Utilities/Utils.cs @@ -402,31 +402,31 @@ namespace FlaxEditor.Utilities /// /// Creates an Import path ui that show the asset import path and adds a button to show the folder in the file system. /// - /// The parent group element. + /// The parent layout element. /// The asset item to get the import path of. - public static void CreateImportPathUI(CustomEditors.Elements.GroupElement group, Content.BinaryAssetItem assetItem) + public static void CreateImportPathUI(CustomEditors.LayoutElementsContainer parentLayout, Content.BinaryAssetItem assetItem) { assetItem.GetImportPath(out var path); - CreateImportPathUI(group, path); + CreateImportPathUI(parentLayout, path); } /// /// Creates an Import path ui that show the import path and adds a button to show the folder in the file system. /// - /// The parent group element. + /// The parent layout element. /// The import path. /// Whether to use an initial layout space of 5 for separation. - public static void CreateImportPathUI(CustomEditors.Elements.GroupElement group, string path, bool useInitialSpacing = true) + public static void CreateImportPathUI(CustomEditors.LayoutElementsContainer parentLayout, string path, bool useInitialSpacing = true) { if (!string.IsNullOrEmpty(path)) { if (useInitialSpacing) - group.Space(0); - var textBox = group.TextBox().TextBox; + parentLayout.Space(0); + var textBox = parentLayout.TextBox().TextBox; textBox.TooltipText = "Source asset path. Can be relative or absolute to the project. Path is not editable here."; textBox.IsReadOnly = true; textBox.Text = path; - var button = group.Button(Constants.ShowInExplorer).Button; + var button = parentLayout.Button(Constants.ShowInExplorer).Button; button.Clicked += () => FileSystem.ShowFileExplorer(Path.GetDirectoryName(path)); } }