(Feat) Tools Update
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using Ashwild.Inventory;
|
||||
@@ -60,6 +61,29 @@ namespace Ashwild.EditorTools
|
||||
return badge;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wraps a name text field in a row prefixed by a small pencil icon, signalling that the title
|
||||
/// is editable. The field grows to fill the remaining width.
|
||||
/// </summary>
|
||||
public static VisualElement EditableNameRow(TextField nameField)
|
||||
{
|
||||
VisualElement row = new VisualElement();
|
||||
row.AddToClassList("ash-namerow");
|
||||
|
||||
Texture pencil = EditorGUIUtility.IconContent("d_editicon.sml").image;
|
||||
if (pencil == null) pencil = EditorGUIUtility.IconContent("editicon.sml").image;
|
||||
if (pencil != null)
|
||||
{
|
||||
Image icon = new Image { image = pencil, scaleMode = ScaleMode.ScaleToFit };
|
||||
icon.AddToClassList("ash-namerow__pencil");
|
||||
row.Add(icon);
|
||||
}
|
||||
|
||||
nameField.style.flexGrow = 1;
|
||||
row.Add(nameField);
|
||||
return row;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user