79 lines
3.0 KiB
C#
79 lines
3.0 KiB
C#
#nullable enable
|
|
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UVC.Data.Core;
|
|
using UVC.UI.Modal;
|
|
using UVC.UI.Tab;
|
|
|
|
namespace UVC.Studio.Modal.Settings
|
|
{
|
|
public class SettingModal : ModalView
|
|
{
|
|
[SerializeField]
|
|
protected TabController? tabController;
|
|
|
|
/// <summary>
|
|
/// 모달이 열릴 때 호출됩니다. (비동기)
|
|
/// </summary>
|
|
/// <param name="content">모달에 표시할 내용/설정</param>
|
|
public override async UniTask OnOpen(ModalContent content)
|
|
{
|
|
await base.OnOpen(content); // 부모의 OnOpen을 먼저 호출해서 기본 UI를 설정해요.
|
|
if (tabController != null)
|
|
{
|
|
// 코드로 탭 설정하기
|
|
SetupTabs(content);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 모달이 닫힐 때 호출됩니다. (비동기)
|
|
/// </summary>
|
|
/// <param name="content">모달에 표시할 내용/설정</param>
|
|
public override async UniTask OnClose(ModalContent content)
|
|
{
|
|
// 현재 활성화된 탭의 OnCloseAsync 호출
|
|
if (tabController != null)
|
|
{
|
|
ITabContent? activeTabContent = tabController.GetActiveITabContent();
|
|
if (activeTabContent != null) await activeTabContent.OnCloseAsync();
|
|
}
|
|
await base.OnClose(content);
|
|
}
|
|
|
|
private void SetupTabs(ModalContent content)
|
|
{
|
|
// 1. TabConfig 설정
|
|
tabController?.AddTabConfig("Database", "Database", "Studio/Prefabs/Modal/Setting/SettingDatabaseTabContent", "Prefabs/UI/Images/icon_db", null, true);
|
|
tabController?.AddTabConfig("General", "General", "Studio/Prefabs/Modal/Setting/SettingGeneralTabContent", "Prefabs/UI/Images/icon_info", null, true);
|
|
tabController?.AddTabConfig("Shortcut", "Shortcut", "Studio/Prefabs/Modal/Setting/SettingShortcutTabContent", "Prefabs/UI/Images/icon_shortcut", null, true);
|
|
|
|
// 2. 컨트롤러 초기화
|
|
tabController?.Initialize();
|
|
|
|
if (tabController != null)
|
|
{
|
|
tabController.OnTabChanged += (index) =>
|
|
{
|
|
Debug.Log($"탭이 변경되었습니다: {index}");
|
|
};
|
|
if(content.Message.StartsWith("shortcut:"))
|
|
{
|
|
// 특정 탭으로 이동
|
|
string parts = content.Message.Substring("shortcut:".Length);
|
|
if (parts.Length > 0)
|
|
{
|
|
//시간차를 계산해 0.5초 후에 탭을 활성화
|
|
//UniTask.Delay(500).ContinueWith(() => {
|
|
Debug.Log($"ActivateTab: {parts[0]}");
|
|
string tabKey = parts;
|
|
tabController.ActivateTab(tabKey, content.Message);
|
|
//});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|