52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class IntroUIManager : MonoBehaviour
|
|
{
|
|
[Header("Menu Settings")]
|
|
public List<MenuButton> MenuButtons; // 인스펙터에서 버튼들을 등록함
|
|
|
|
private MenuLogic _menu; // 내부적으로 로직 객체를 들고 있음
|
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
private void Start()
|
|
{
|
|
SetMenuLogic(new MenuLogic(MenuButtons));
|
|
|
|
InputManager.Instance.SetUIInputMap("IntroUI");
|
|
}
|
|
|
|
private void SetMenuLogic(MenuLogic menuLogic)
|
|
{
|
|
//혹시라도 나중에 이벤트를 재할당할 일이 있다면 반드시 기존 이벤트는 해제하고 연결해야함
|
|
if(_menu != null)
|
|
{
|
|
InputManager.Instance.OnKeyDown_UpArrowEvent -= _menu.MenuMoveUp;
|
|
InputManager.Instance.OnKeyDown_DownArrowEvent -= _menu.MenuMoveDown;
|
|
InputManager.Instance.OnKeyDown_EnterEvent -= _menu.MenuConfirm;
|
|
}
|
|
|
|
_menu = menuLogic;
|
|
|
|
InputManager.Instance.OnKeyDown_UpArrowEvent += _menu.MenuMoveUp;
|
|
InputManager.Instance.OnKeyDown_DownArrowEvent += _menu.MenuMoveDown;
|
|
InputManager.Instance.OnKeyDown_EnterEvent += _menu.MenuConfirm;
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
private void Update()
|
|
{
|
|
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
InputManager.Instance.OnKeyDown_UpArrowEvent -= _menu.MenuMoveUp;
|
|
InputManager.Instance.OnKeyDown_DownArrowEvent -= _menu.MenuMoveDown;
|
|
InputManager.Instance.OnKeyDown_EnterEvent -= _menu.MenuConfirm;
|
|
}
|
|
}
|