You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.7 KiB
53 lines
1.7 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections.Generic;
|
||
|
using AX.MessageSystem;
|
||
|
using System;
|
||
|
|
||
|
public class ExaminationPaperList : MonoBehaviour {
|
||
|
|
||
|
// Use this for initialization
|
||
|
public GameObject itemPrefab;
|
||
|
public GameObject detail;
|
||
|
public List<ExaminationPaperObject> paperList = new List<ExaminationPaperObject>();
|
||
|
void Start()
|
||
|
{
|
||
|
MessageDispatcher.AddListener("SHOW_PAPER_DETAIL", showDetail);
|
||
|
MessageDispatcher.AddListener("PAPER_PAGE_REFRESH", showPaperList);
|
||
|
}
|
||
|
|
||
|
void OnDestroy()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("SHOW_PAPER_DETAIL", showDetail);
|
||
|
MessageDispatcher.RemoveListener("PAPER_PAGE_REFRESH", showPaperList);
|
||
|
}
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
//刷新列表信息
|
||
|
private void showPaperList(IMessage message)
|
||
|
{
|
||
|
PagingReplyInfo<ExaminationPaperObject> pair = (PagingReplyInfo<ExaminationPaperObject>)(message.Data);
|
||
|
paperList = pair.Items;
|
||
|
foreach (Transform child in this.transform)
|
||
|
{
|
||
|
Destroy(child.gameObject);
|
||
|
}
|
||
|
foreach (ExaminationPaperObject paper in paperList)
|
||
|
{
|
||
|
GameObject item = Instantiate(itemPrefab) as GameObject;
|
||
|
item.transform.parent = this.transform;
|
||
|
item.transform.localScale = new Vector3(1, 1, 1);
|
||
|
item.name = "Item";
|
||
|
item.GetComponent<ExaminationPaperMessage>().setPaper(paper);
|
||
|
}
|
||
|
}
|
||
|
private void showDetail(IMessage message)
|
||
|
{
|
||
|
ExaminationPaperObject exam = (ExaminationPaperObject)(message.Data);
|
||
|
detail.SetActive(true);
|
||
|
detail.GetComponent<ExaminationPaperDetail>().showDetail(exam);
|
||
|
}
|
||
|
}
|