UIToolkit Sample uxml로 전환
This commit is contained in:
@@ -35,7 +35,7 @@ namespace UVC.UIToolkit
|
||||
}
|
||||
|
||||
/// <summary>활성화 상태</summary>
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("is-enabled")]
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace UVC.UIToolkit
|
||||
}
|
||||
|
||||
/// <summary>활성화 상태</summary>
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("is-enabled")]
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace UVC.UIToolkit
|
||||
}
|
||||
|
||||
/// <summary>플레이스홀더 텍스트</summary>
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("placeholder")]
|
||||
public string Placeholder
|
||||
{
|
||||
get => textEdition.placeholder;
|
||||
@@ -92,7 +92,7 @@ namespace UVC.UIToolkit
|
||||
}
|
||||
|
||||
/// <summary>에러 메시지</summary>
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("error-message")]
|
||||
public string ErrorMessage
|
||||
{
|
||||
get => _errorMessage;
|
||||
@@ -104,7 +104,7 @@ namespace UVC.UIToolkit
|
||||
}
|
||||
|
||||
/// <summary>활성화 상태</summary>
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("is-enabled")]
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
@@ -139,7 +139,7 @@ namespace UVC.UIToolkit
|
||||
}
|
||||
|
||||
/// <summary>스타일 변형</summary>
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("variant")]
|
||||
public InputFieldVariant Variant
|
||||
{
|
||||
get => _variant;
|
||||
@@ -176,10 +176,9 @@ namespace UVC.UIToolkit
|
||||
SubscribeToThemeChanges();
|
||||
|
||||
// UXML에서 로드될 때 속성이 설정된 후 UI 갱신
|
||||
RegisterCallback<AttachToPanelEvent>(_ =>
|
||||
{
|
||||
UpdateVariant();
|
||||
});
|
||||
// Unity 6의 소스 생성기는 Deserialize에서 필드에 직접 값을 할당하므로
|
||||
// AttachToPanelEvent를 사용하여 패널에 연결된 후 UI를 갱신
|
||||
RegisterCallback<AttachToPanelEvent>(OnAttachToPanel);
|
||||
}
|
||||
|
||||
public UTKInputField(string label, string placeholder = "") : this()
|
||||
@@ -237,6 +236,17 @@ namespace UVC.UIToolkit
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
private void OnAttachToPanel(AttachToPanelEvent evt)
|
||||
{
|
||||
// UXML 속성이 설정된 후 한 번만 UI 갱신
|
||||
UnregisterCallback<AttachToPanelEvent>(OnAttachToPanel);
|
||||
UpdateVariant();
|
||||
|
||||
// IsEnabled 상태 적용
|
||||
SetEnabled(_isEnabled);
|
||||
EnableInClassList("utk-input--disabled", !_isEnabled);
|
||||
}
|
||||
|
||||
private void OnTextValueChanged(ChangeEvent<string> evt)
|
||||
{
|
||||
OnValueChanged?.Invoke(evt.newValue);
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace UVC.UIToolkit
|
||||
}
|
||||
|
||||
/// <summary>활성화 상태</summary>
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("is-enabled")]
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace UVC.UIToolkit
|
||||
}
|
||||
|
||||
/// <summary>활성화 상태</summary>
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("is-enabled")]
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UVC.UIToolkit.Common;
|
||||
|
||||
namespace UVC.UIToolkit.Input
|
||||
namespace UVC.UIToolkit
|
||||
{
|
||||
/// <summary>
|
||||
/// 숫자 입력 필드에 위/아래 스테퍼 버튼이 붙은 컴포넌트
|
||||
@@ -19,14 +18,14 @@ namespace UVC.UIToolkit.Input
|
||||
#endregion
|
||||
|
||||
#region UXML Attributes
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("value")]
|
||||
public int Value
|
||||
{
|
||||
get => _value;
|
||||
set => SetValue(value);
|
||||
}
|
||||
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("min-value")]
|
||||
public int MinValue
|
||||
{
|
||||
get => _minValue;
|
||||
@@ -37,7 +36,7 @@ namespace UVC.UIToolkit.Input
|
||||
}
|
||||
}
|
||||
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("max-value")]
|
||||
public int MaxValue
|
||||
{
|
||||
get => _maxValue;
|
||||
@@ -48,14 +47,14 @@ namespace UVC.UIToolkit.Input
|
||||
}
|
||||
}
|
||||
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("step")]
|
||||
public int Step
|
||||
{
|
||||
get => _step;
|
||||
set => _step = Math.Max(1, value);
|
||||
}
|
||||
|
||||
[UxmlAttribute]
|
||||
[UxmlAttribute("wrap-around")]
|
||||
public bool WrapAround
|
||||
{
|
||||
get => _wrapAround;
|
||||
@@ -185,6 +184,13 @@ namespace UVC.UIToolkit.Input
|
||||
ClampValue();
|
||||
}
|
||||
|
||||
/// <summary>컴포넌트의 활성화 상태를 설정합니다.</summary>
|
||||
public new void SetEnabled(bool enabled)
|
||||
{
|
||||
base.SetEnabled(enabled);
|
||||
EnableInClassList("utk-number-stepper--disabled", !enabled);
|
||||
}
|
||||
|
||||
/// <summary>텍스트 필드에 포커스를 설정합니다.</summary>
|
||||
public new void Focus()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user