Files
BABA_YAGA/Packages/app.rive.rive-unity/Editor/Components/CustomElements/WidthHeightDimensionsField.cs

51 lines
1.6 KiB
C#
Raw Normal View History

2026-05-19 17:39:03 +07:00
using UnityEngine.UIElements;
using UnityEditor.UIElements;
using UnityEditor;
namespace Rive.EditorTools
{
/// <summary>
/// A field for editing a Vector2Int representing width and height.
/// </summary>
internal class WidthHeightDimensionsField : VisualElement
{
public IntegerField WidthField { get; private set; }
public IntegerField HeightField { get; private set; }
public WidthHeightDimensionsField(string label, string widthLabel = "Width", string heightLabel = "Height", string tooltip = null)
{
var foldout = new Foldout
{
text = label,
tooltip = tooltip,
value = true // Start expanded
};
Add(foldout);
var container = new VisualElement();
foldout.Add(container);
WidthField = new IntegerField(widthLabel)
{
style = { marginTop = 4 }
};
WidthField.AddToClassList(BaseField<int>.alignedFieldUssClassName);
container.Add(WidthField);
HeightField = new IntegerField(heightLabel)
{
style = { marginTop = 4 }
};
HeightField.AddToClassList(BaseField<int>.alignedFieldUssClassName);
container.Add(HeightField);
}
public void BindProperty(SerializedProperty property)
{
WidthField.BindProperty(property.FindPropertyRelative("x"));
HeightField.BindProperty(property.FindPropertyRelative("y"));
}
}
}