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.6 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Level2
{
public class TogglePanel : TogglePaneExample
{
public Button openBtn;
public Button closeBtn;
public GameObject main;
Question question;
protected override void Awake()
{
base.Awake();
openBtn.onClick.AddListener(() => { closeBtn.gameObject.SetActive(true); main.SetActive(true); openBtn.gameObject.SetActive(false); });
closeBtn.onClick.AddListener(() => { openBtn.gameObject.SetActive(true); main.SetActive(false); });
}
protected override void Init()
{
base.Init();
closeBtn.gameObject.SetActive(true);
openBtn.gameObject.SetActive(false);
}
public override void UpdateShow()
{
question = GameManager.Instance.GetQuestion();
title.text = question.title;
for (int i = 0; i < toggles.transform.GetComponentsInChildren<Toggle>().Length; i++)
{
toggles.transform.GetChild(i).GetComponentInChildren<Text>().text = question.content[i];
}
}
public override void EmitCallBack()
{
if (answers[question.answer] == true)
{
GameManager.Instance.QuestionCallBack();
GameManager.Instance.questionIndex++;
gameObject.SetActive(false);
}
else
{
GameManager.Instance.ui.ShowErrorTip("操作错误,请重试");
}
}
}
}