Repository navigation
UIEventWindow
김광수 edited this page Oct 16, 2023
·
2 revisions
이벤트에 진입했을때 나오게될 UI창
-
eventInfoSO
- 이벤트의 정보를 저장
-
eventName
- 이벤트 이름의 TextMeshProUGUI
-
eventInfo
- 이벤트 내용의 TextMeshProUGUI
-
selectButtonList
- 연결된 UIButton들을 리스트로 저장
- Init()
- 이벤트 창을 호출하는 부분에서 Init()메서드를 호출하여 UIEventWindow를 초기화한다.
- EventInfoSO를 받아서 eventInfoSO에 저장한다.
- eventInfoSO의 내용을 바탕으로 UI를 업데이트한다.
- 연결된 Button들의 event에 eventFuncSO의 Use()를 연결한다.
using System.Collections.Generic;
using System.Reflection;
using TMPro;
public class UIEventWindow : UIBase
{
// SO로 Event에 대한 정보를 받아온다.
// 해당 정보를 통해서 UI를 수정한다.
// SO에 버튼
public EventInfoSO eventInfoSO;
public TextMeshProUGUI eventName;
public TextMeshProUGUI eventInfo;
public List<UIButton> selectButtonList = new List<UIButton>();
public void Init(EventInfoSO so)
{
eventInfoSO = so;
eventName.text = eventInfoSO.eventName;
eventInfo.text = eventInfoSO.eventInfo;
for (int i =0; i< selectButtonList.Count; i++)
{
if (i >= eventInfoSO.selectEventInfo.Count)
{
selectButtonList[i].gameObject.SetActive(false);
continue;
}
selectButtonList[i].gameObject.SetActive(true);
selectButtonList[i].OnClick += eventInfoSO.selectEventFunc[i].OnUse;
selectButtonList[i].GetComponentInChildren<TextMeshProUGUI>().text = eventInfoSO.selectEventInfo[i];
}
}
}