65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
using System;
|
|
using UnityEngine.UI;
|
|
using ZXKFramework;
|
|
namespace DongWuYiXue.DaoNiaoShu
|
|
{
|
|
public class TxtSelectQuestionPanel : UIBase
|
|
{
|
|
public override string GroupName => "TxtSelectQuestionPanel";
|
|
public override string Name => "TxtSelectQuestionPanel";
|
|
|
|
public Action nextAction;
|
|
public Action<bool> subAction;
|
|
TxtSelectManager[] txtSelectManagers;
|
|
Button nextBtn;
|
|
Button subBtn;
|
|
int id;
|
|
public override void Init(IUIManager uictrl)
|
|
{
|
|
base.Init(uictrl);
|
|
txtSelectManagers = GetComponentsInChildren<TxtSelectManager>(true);
|
|
nextBtn = transform.FindFirst<Button>("Next");
|
|
nextBtn.onClick.AddListener(Next);
|
|
subBtn = transform.FindFirst<Button>("Submit");
|
|
subBtn.onClick.AddListener(Submit);
|
|
}
|
|
private void Submit()
|
|
{
|
|
if (txtSelectManagers[id].Check())
|
|
{
|
|
subAction?.Invoke(true);
|
|
}
|
|
else
|
|
{
|
|
subAction?.Invoke(false);
|
|
}
|
|
subBtn.gameObject.SetActive(false);
|
|
nextBtn.gameObject.SetActive(true);
|
|
}
|
|
private void Next()
|
|
{
|
|
SetActive(false);
|
|
subBtn.gameObject.SetActive(true);
|
|
nextBtn.gameObject.SetActive(false);
|
|
nextAction?.Invoke();
|
|
}
|
|
public void ShowImgQuestion(int id)
|
|
{
|
|
SetActive(true);
|
|
subBtn.gameObject.SetActive(true);
|
|
this.id = id;
|
|
for (int i = 0; i < txtSelectManagers.Length; i++)
|
|
{
|
|
if (i == id)
|
|
{
|
|
txtSelectManagers[i].gameObject.SetActive(true);
|
|
txtSelectManagers[i].Init();
|
|
}
|
|
else
|
|
{
|
|
txtSelectManagers[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |