98 lines
3.2 KiB
C#
98 lines
3.2 KiB
C#
#nullable enable
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
using UVC.UIToolkit;
|
|
using UVC.UI.Commands;
|
|
using UVC.Log;
|
|
using UVC.Studio.UIToolkit.Modal;
|
|
|
|
namespace UVC.Sample.UIToolkit
|
|
{
|
|
/// <summary>
|
|
/// UTKSettingModalSample 독립 실행 샘플 코드입니다.
|
|
/// </summary>
|
|
public class UTKSettingModalSample : MonoBehaviour
|
|
{
|
|
[SerializeField] private UIDocument? _uiDocument;
|
|
|
|
[SerializeField]
|
|
[Tooltip("시작 시 적용할 테마")]
|
|
private UTKTheme initialTheme = UTKTheme.Dark;
|
|
|
|
private UTKToggle? _themeToggle;
|
|
private VisualElement? _root;
|
|
|
|
private UTKButton? _openButton0;
|
|
private UTKButton? _openButton1;
|
|
private UTKButton? _openButton2;
|
|
|
|
private void Start()
|
|
{
|
|
// UIDocument 참조 확인
|
|
var doc = GetComponent<UIDocument>();
|
|
if (doc == null)
|
|
{
|
|
Debug.LogError("UIDocument가 할당되지 않았습니다.");
|
|
return;
|
|
}
|
|
_uiDocument = doc;
|
|
_root = _uiDocument.rootVisualElement;
|
|
UTKModal.SetRoot(_root);
|
|
UTKThemeManager.Instance.RegisterRoot(_root);
|
|
UTKThemeManager.Instance.SetTheme(initialTheme);
|
|
|
|
// 테마 토글
|
|
_themeToggle = _root.Q<UTKToggle>("toggle");
|
|
if (_themeToggle != null)
|
|
{
|
|
_themeToggle.OnValueChanged += (isOn) =>
|
|
{
|
|
UTKThemeManager.Instance.SetTheme(!isOn ? UTKTheme.Dark : UTKTheme.Light);
|
|
};
|
|
}
|
|
|
|
_openButton0 = _root.Q<UTKButton>("openButton0");
|
|
if (_openButton0 != null) {
|
|
_openButton0.OnClicked += async () =>
|
|
{
|
|
var modal = UTKModal.Create("Settings", UTKModal.ModalSize.Large);
|
|
var content = new UTKSettingModalContent(0); // 초기 탭 인덱스 설정
|
|
modal.Add(content);
|
|
await modal.ShowAsync();
|
|
};
|
|
}
|
|
|
|
_openButton1 = _root.Q<UTKButton>("openButton1");
|
|
if (_openButton1 != null) {
|
|
_openButton1.OnClicked += async () =>
|
|
{
|
|
var modal = UTKModal.Create("Settings", UTKModal.ModalSize.Large);
|
|
var content = new UTKSettingModalContent(1); // 초기 탭 인덱스 설정
|
|
modal.Add(content);
|
|
await modal.ShowAsync();
|
|
};
|
|
}
|
|
|
|
_openButton2 = _root.Q<UTKButton>("openButton2");
|
|
if (_openButton2 != null) {
|
|
_openButton2.OnClicked += async () =>
|
|
{
|
|
var modal = UTKModal.Create("Settings", UTKModal.ModalSize.Large);
|
|
var content = new UTKSettingModalContent(2); // 초기 탭 인덱스 설정
|
|
modal.Add(content);
|
|
await modal.ShowAsync();
|
|
};
|
|
}
|
|
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
|
|
|
|
ULog.Debug("UTKSettingModalSample 정리 완료");
|
|
}
|
|
}
|
|
}
|