(Feat) Tools Update

This commit is contained in:
2026-06-23 14:52:45 +02:00
parent 6527f559e1
commit c9b085ebea
4 changed files with 42 additions and 3 deletions
@@ -204,6 +204,19 @@
flex-grow: 1;
}
.ash-namerow {
flex-direction: row;
align-items: center;
}
.ash-namerow__pencil {
width: 13px;
height: 13px;
margin-right: 6px;
margin-bottom: 6px;
opacity: 0.55;
}
.ash-hero__name {
margin-bottom: 6px;
}
@@ -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
}
}
@@ -114,7 +114,7 @@ namespace Ashwild.EditorTools
nameField.AddToClassList("ash-hero__name");
nameField.BindProperty(so.FindProperty("itemName"));
nameField.RegisterValueChangedCallback(_ => onMetaChanged?.Invoke());
info.Add(nameField);
info.Add(AshwildUI.EditableNameRow(nameField));
VisualElement typeRow = new VisualElement();
typeRow.AddToClassList("ash-hero__typerow");
@@ -68,10 +68,12 @@ namespace Ashwild.EditorTools
{
TextField nameField = new TextField();
nameField.AddToClassList("ash-hero__name");
nameField.AddToClassList("ash-recipe-name");
nameField.BindProperty(so.FindProperty("recipeName"));
nameField.RegisterValueChangedCallback(_ => onMetaChanged?.Invoke());
return nameField;
VisualElement row = AshwildUI.EditableNameRow(nameField);
row.AddToClassList("ash-recipe-name");
return row;
}
#endregion