(Feat) Tools Update
This commit is contained in:
@@ -204,6 +204,19 @@
|
|||||||
flex-grow: 1;
|
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 {
|
.ash-hero__name {
|
||||||
margin-bottom: 6px;
|
margin-bottom: 6px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UIElements;
|
using UnityEngine.UIElements;
|
||||||
using Ashwild.Inventory;
|
using Ashwild.Inventory;
|
||||||
@@ -60,6 +61,29 @@ namespace Ashwild.EditorTools
|
|||||||
return badge;
|
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
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace Ashwild.EditorTools
|
|||||||
nameField.AddToClassList("ash-hero__name");
|
nameField.AddToClassList("ash-hero__name");
|
||||||
nameField.BindProperty(so.FindProperty("itemName"));
|
nameField.BindProperty(so.FindProperty("itemName"));
|
||||||
nameField.RegisterValueChangedCallback(_ => onMetaChanged?.Invoke());
|
nameField.RegisterValueChangedCallback(_ => onMetaChanged?.Invoke());
|
||||||
info.Add(nameField);
|
info.Add(AshwildUI.EditableNameRow(nameField));
|
||||||
|
|
||||||
VisualElement typeRow = new VisualElement();
|
VisualElement typeRow = new VisualElement();
|
||||||
typeRow.AddToClassList("ash-hero__typerow");
|
typeRow.AddToClassList("ash-hero__typerow");
|
||||||
|
|||||||
@@ -68,10 +68,12 @@ namespace Ashwild.EditorTools
|
|||||||
{
|
{
|
||||||
TextField nameField = new TextField();
|
TextField nameField = new TextField();
|
||||||
nameField.AddToClassList("ash-hero__name");
|
nameField.AddToClassList("ash-hero__name");
|
||||||
nameField.AddToClassList("ash-recipe-name");
|
|
||||||
nameField.BindProperty(so.FindProperty("recipeName"));
|
nameField.BindProperty(so.FindProperty("recipeName"));
|
||||||
nameField.RegisterValueChangedCallback(_ => onMetaChanged?.Invoke());
|
nameField.RegisterValueChangedCallback(_ => onMetaChanged?.Invoke());
|
||||||
return nameField;
|
|
||||||
|
VisualElement row = AshwildUI.EditableNameRow(nameField);
|
||||||
|
row.AddToClassList("ash-recipe-name");
|
||||||
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user