using System.Collections; using System.Collections.Generic; using TMPro; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; public class SelectScenePanel : MonoBehaviour { public GameObject schoolPrefab;//滑动视图预制体 public Transform schoolList;//预制体列表 public ToggleGroup schooltoggleGroup; public Toggle[] toggleList; public GameObject scoolSelectBtn;//学校选择按钮 public GameObject schoolChoiceLable;//学校选择界面 public GameObject eventChoiceLable;//事件选择界面 public bool isOpen = false; public List schoolInfos = new List();//学校信息 public List eventInfos = new List();//事件信息 public List difficultyList = new List(); //数据 public int schoolId; public string schoolName; public int eventId; public string eventName; public string difficulty; // Start is called before the first frame update void Start() { schoolChoiceLable.gameObject.SetActive(true); eventChoiceLable.gameObject.SetActive(false); //动态加载学校选择预制体 for (int i=0;i<6;i++) { GameObject slot = GameObject.Instantiate(schoolPrefab, schoolList); //schoolPrefab.gameObject.GetComponent().sprite = Resources.Load(""); } } // Update is called once per frame void Update() { } //学校选择,确定学校信息 public void SelectSchoolBtn() { SchoolInfo gameObject = GetComponentInChildren(); foreach (SchoolInfo item in schoolInfos) { if(item.gameObject.transform.GetComponent().isOn) { this.schoolId = item.schoolId; this.schoolName = item.schoolName; } } Debug.Log("###############1:"+ this.schoolId); Debug.Log("###############2:" + this.schoolName); } //事件及难度选择 public void SelectEvent() { EventInfo eventInfo = GetComponentInChildren(); foreach(EventInfo item in eventInfos) { if (item.gameObject.transform.GetComponent().isOn) { Debug.Log(item.eventId); this.eventId = item.eventId; this.eventName = item.eventName; } } Debug.Log("%%%%%%%%%%%%%1:"+ this.eventId); Debug.Log("%%%%%%%%%%%%%2:" + this.eventName); } //游戏难度选择 public void SelsctDifficulty() { foreach(Toggle item in difficultyList) { if (item.isOn) { this.difficulty = item.transform.parent.GetComponentInChildren().text; } } Debug.Log("%%%%%%%%%%%%%3:" + this.difficulty); } //继续按钮,点击后上传数据 public void ContinueBtn() { SelectSchoolBtn(); schoolChoiceLable.gameObject.SetActive(false); eventChoiceLable.gameObject.SetActive(true); } //提交按钮,点击上传数据和隐藏界面 public void SubmitBtn() { SelectEvent(); SelsctDifficulty(); this.gameObject.SetActive(false); } }