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.
48 lines
1.6 KiB
48 lines
1.6 KiB
3 years ago
|
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<ExaminationQuestionObject> questionList = new List<ExaminationQuestionObject>();
|
||
|
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<ExaminationQuestionObject> pair = (PagingReplyInfo<ExaminationQuestionObject>)(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<ExaminationQuestionSelectedMessage>().setQuestion(question);
|
||
|
//item.transform.FindChild("Toggle").GetComponent<Toggle>().group = GetComponent<ToggleGroup>();
|
||
|
if (ExaminationPaperDetail.questionId.Contains(question.ID.ToString()))
|
||
|
{
|
||
|
item.transform.Find("Toggle").GetComponent<Toggle>().isOn = true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|