58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UIQuitAll : UIBase
|
|
{
|
|
public Button close;
|
|
public List<Button> questions;
|
|
|
|
List<DataItem2> currentPeoplesQuestion;
|
|
|
|
|
|
public Transform content;
|
|
public GameObject button;
|
|
|
|
private void Awake()
|
|
{
|
|
close.onClick.AddListener(() =>
|
|
{
|
|
UIManager.Instance.DestoryUI(UIType.UIQuitAll);
|
|
UIManager.Instance.ShowMainUI();
|
|
});
|
|
//for (int i = 0; i < questions.Length; i++)
|
|
//{
|
|
// questions[i].onClick.AddListener(() => { UIManager.Instance.OpenUI(UIType.UIAnswer); });
|
|
//}
|
|
currentPeoplesQuestion = new List<DataItem2>();
|
|
questions = new List<Button>();
|
|
var allQuestion = DataManager.Instance.currentPeoplesQuestion;
|
|
for (int i = 0; i < allQuestion.Count; i++)
|
|
{
|
|
if (allQuestion[i].type == 4)
|
|
{
|
|
currentPeoplesQuestion.Add(allQuestion[i]);
|
|
}
|
|
}
|
|
for (int i = 0; i < currentPeoplesQuestion.Count; i++)
|
|
{
|
|
var newUI = GameObject.Instantiate(button, content);
|
|
newUI.SetActive(true);
|
|
var tempData = currentPeoplesQuestion[i];
|
|
newUI.GetComponentInChildren<TextMeshProUGUI>().text = tempData.title;
|
|
var btn = newUI.GetComponent<Button>();
|
|
questions.Add(btn);
|
|
}
|
|
for (int i = 0; i < questions.Count; i++)
|
|
{
|
|
questions[i].onClick.AddListener(() =>
|
|
{
|
|
DataManager.Instance.currentQuitQuestion = currentPeoplesQuestion[i];
|
|
UIManager.Instance.OpenUI(UIType.UIAnswer);
|
|
});
|
|
}
|
|
}
|
|
}
|