using UnityEngine; using System.Collections.Generic; using UnityEngine.UI; using AX.MessageSystem; public class AllQuestionSelect : MonoBehaviour { public GameObject itemPrefab; public ExaminationInfo exam; public static QuestionInfo question;//选中的题目 public GameObject scorePanel; public GameObject list; void Start() { //MessageDispatcher.AddListener("QUESTION_PAGE_REFRESH", showQuestionList); } void OnDestroy() { //MessageDispatcher.RemoveListener("QUESTION_PAGE_REFRESH", showQuestionList); } // Update is called once per frame void Update() { } public void showQuestionList(ExaminationInfo exam) { this.exam= exam; var questionList = exam.QuestionInfos; foreach (Transform child in this.transform) { Destroy(child.gameObject); } foreach (QuestionInfo question in questionList) { GameObject item = Instantiate(itemPrefab) as GameObject; item.transform.parent = this.transform; item.transform.localScale = new Vector3(1, 1, 1); item.name = "Item"; item.GetComponent().setQuestion(question); item.GetComponent().group = GetComponent(); } } public void submitSelected() { var scoreList = exam.ScoreInfos; var scores = new List(); foreach (ScoreInfo score in scoreList) { if (score.QuestionID== question.ID) { scores.Add(score); } } scorePanel.SetActive(true); list.GetComponent().showScoreList(scores); } }