make path creation method more generalized

This commit is contained in:
xxSeys1
2025-05-02 13:29:01 +02:00
parent e568e6e17b
commit f5ad8566eb

View File

@@ -402,31 +402,31 @@ namespace FlaxEditor.Utilities
/// <summary>
/// Creates an Import path ui that show the asset import path and adds a button to show the folder in the file system.
/// </summary>
/// <param name="group">The parent group element.</param>
/// <param name="parentLayout">The parent layout element.</param>
/// <param name="assetItem">The asset item to get the import path of.</param>
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);
}
/// <summary>
/// Creates an Import path ui that show the import path and adds a button to show the folder in the file system.
/// </summary>
/// <param name="group">The parent group element.</param>
/// <param name="parentLayout">The parent layout element.</param>
/// <param name="path">The import path.</param>
/// <param name="useInitialSpacing">Whether to use an initial layout space of 5 for separation.</param>
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));
}
}