com.alicizax.unity.editor.e.../Editor/Toolbar/RecommendedStyles/TextFieldRecommendedStyle.cs
2025-08-01 19:32:29 +08:00

30 lines
810 B
C#

using UnityEngine.UIElements;
namespace Paps.UnityToolbarExtenderUIToolkit
{
internal class TextFieldRecommendedStyle : RecommendedStyle
{
private const int MIN_WIDTH = 120;
private TextField _textField;
public TextFieldRecommendedStyle(TextField textField)
{
_textField = textField;
}
protected override void ApplyRootElementStyle()
{
var inputFieldIndex = 1;
if (string.IsNullOrEmpty(_textField.label))
inputFieldIndex = 0;
var inputElement = _textField[inputFieldIndex];
_textField.labelElement.style.minWidth = Length.Auto();
inputElement.style.minWidth = MIN_WIDTH;
inputElement.style.overflow = Overflow.Visible;
}
}
}