using System.Collections; using System.Collections.Generic; using UnityEngine; using XWFramework.UI; using UnityEngine.UI; namespace Level1 { 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().Length; i++) { toggles.transform.GetChild(i).GetComponentInChildren().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("操作错误,请重试"); } } } }