64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
public class SelectPanel : UIController
|
|
{
|
|
public List<string> data;
|
|
[SerializeField] Button dataBtn;
|
|
[SerializeField] Transform trans;
|
|
[SerializeField] popUp popUp;
|
|
List<Button> ListBtn = new List<Button>();
|
|
[SerializeField] List<Transform> tran;
|
|
public GameObject g1;
|
|
[SerializeField] Button ReturnBtn;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
try
|
|
{
|
|
//init();
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
Debug.Log("¿ÉÄÜÊÇÒ»¸öС´íÎó"+ex.Message);
|
|
throw;
|
|
}
|
|
}
|
|
public void init()
|
|
{
|
|
ReturnBtn.onClick.AddListener(() =>
|
|
{
|
|
g1?.SetActive(true);
|
|
gameObject?.SetActive(false);
|
|
}) ;
|
|
for (int i = 0; i < data.Count; i++)
|
|
{
|
|
ListBtn.Add(Instantiate(dataBtn,tran[i]));
|
|
}
|
|
for (int i = 0; i < ListBtn.Count; i++)
|
|
{
|
|
ListBtn[i].transform.name = i.ToString();
|
|
var temp = data[i].Split(',');
|
|
ListBtn[i].GetComponentInChildren<TextMeshProUGUI>().text = temp[0];
|
|
}
|
|
foreach (var item in ListBtn)
|
|
{
|
|
item.onClick.AddListener(() =>
|
|
{
|
|
popUp.content = data[int.Parse(item.name)];
|
|
popUp.ac = () =>
|
|
{
|
|
SceneManager.LoadScene("MainScenes");
|
|
popUp.gameObject.SetActive(false);
|
|
};
|
|
popUp.gameObject.SetActive(true);
|
|
popUp.init();
|
|
});
|
|
}
|
|
}
|
|
}
|