라이브러리 정리
This commit is contained in:
64
Assets/Scripts/Factory/Modal/Settings/SettingModal.cs
Normal file
64
Assets/Scripts/Factory/Modal/Settings/SettingModal.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
#nullable enable
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UVC.Data.Core;
|
||||
using UVC.UI.Modal;
|
||||
using UVC.UI.Tab;
|
||||
|
||||
namespace UVC.Factory.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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SetupTabs(ModalContent content)
|
||||
{
|
||||
// 1. TabConfig 설정
|
||||
tabController?.AddTabConfig("GeneralInfo", "일반 정보", "Prefabs/Factory/Modal/Setting/GeneralInfoTabContent", "Prefabs/UI/Images/icon_info", null, true);
|
||||
tabController?.AddTabConfig("DisplaySetting", "표시 설정", "Prefabs/Factory/Modal/Setting/DisplaySettingTabContent", "Prefabs/UI/Images/icon_eye", null, true);
|
||||
tabController?.AddTabConfig("AlarmSetting", "알람 설정", "Prefabs/Factory/Modal/Setting/AlarmSettingTabContent", "Prefabs/UI/Images/icon_alarm", null, true);
|
||||
tabController?.AddTabConfig("InputSetting", "입력 설정", "Prefabs/Factory/Modal/Setting/InputSettingTabContent", "Prefabs/UI/Images/icon_mouse", 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).Split('>');
|
||||
if (parts.Length > 0)
|
||||
{
|
||||
//시간차를 계산해 0.5초 후에 탭을 활성화
|
||||
UniTask.Delay(500).ContinueWith(() => {
|
||||
Debug.Log($"ActivateTab: {parts[0]}");
|
||||
string tabKey = parts[0];
|
||||
tabController.ActivateTab(tabKey, content.Message);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user