using UnityEngine; using System.Collections.Generic; using AX.MessageSystem; public class ExaminationQuestionList : MonoBehaviour { // Use this for initialization public GameObject itemPrefab; public List questionList = new List(); void Start () { ExamInfoHelpClass.loadSceneMode = ExamInfoHelpClass.LoadSceneMode.CreatQuestion; 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); } } }