using UnityEngine; using System.Collections.Generic; using UnityEngine.UI; using AX.MessageSystem; public class ExaminationQuestionSelectedList : MonoBehaviour { // Use this for initialization public GameObject itemPrefab; public List questionList = new 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() { } private void showQuestionList(IMessage message) { PagingReplyInfo pair = (PagingReplyInfo)(message.Data); questionList = pair.Items; foreach (Transform child in this.transform) { Destroy(child.gameObject); } foreach (ExaminationQuestionObject 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.transform.FindChild("Toggle").GetComponent().group = GetComponent(); if (ExaminationPaperDetail.questionId.Contains(question.ID.ToString())) { item.transform.Find("Toggle").GetComponent().isOn = true; } } } }