loudixvmuniu/Assets/_Scripts/Application/UI/ExplainContainPanel.cs

86 lines
2.4 KiB
C#
Raw Normal View History

2025-01-02 12:15:45 +08:00
using CG.Framework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/*******************************************************************************
*Create By CG
*Function
*******************************************************************************/
namespace ZXK.LouDiXvMuNiu
{
public class ExplainContainPanel : UIBase
{
private Toggle _trainTog = null;
private Toggle _handlerTog = null;
private GameObject _trainGeo = null;
private GameObject _handlerGeo = null;
private Button _closeBtn = null;
2025-01-14 15:34:07 +08:00
private Toggle _popLoop = null;
private bool _isFirstEnter = false;
private int _clickNumber = 0;
2025-01-02 12:15:45 +08:00
protected override void Awake()
{
base.Awake();
_trainTog = GetWedage("TrainingInstruction_N").GetComponent<Toggle>();
_handlerTog = GetWedage("OperationInstruction_N").GetComponent<Toggle>();
_trainGeo = GetWedage("TrainExplainBG_N");
_handlerGeo = GetWedage("HandlerExplainBG_N");
_closeBtn = GetWedage("CloseBtn_N").GetComponent<Button>();
2025-01-14 15:34:07 +08:00
_popLoop = GetWedage("LoopPopSet_N").GetComponent<Toggle>();
//InitUIState();
2025-01-02 12:15:45 +08:00
CG.UTility.PopUpMng._TriAble = false;
2025-01-14 15:34:07 +08:00
_clickNumber = 0;
_popLoop.isOn = !GameManager.Instance._loopPopExplain;
2025-01-02 12:15:45 +08:00
}
public void InitUIState(bool AutoPop,System.Action firstCloseCallBack = null)
2025-01-14 15:34:07 +08:00
{
_isFirstEnter = AutoPop;
_popLoop.gameObject.SetActive(AutoPop);
2025-01-14 15:34:07 +08:00
_popLoop.onValueChanged.AddListener((isOn) =>
{
GameManager.Instance._loopPopExplain = !isOn;
2025-01-14 15:34:07 +08:00
});
2025-01-02 12:15:45 +08:00
_trainTog.onValueChanged.AddListener((isOn) =>
{
_trainGeo.SetActive(isOn);
2025-01-14 15:34:07 +08:00
if (isOn)
_clickNumber++;
2025-01-02 12:15:45 +08:00
});
_handlerTog.onValueChanged.AddListener((isOn) =>
{
_handlerGeo.SetActive(isOn);
2025-01-14 15:34:07 +08:00
if (isOn)
_clickNumber++;
2025-01-02 12:15:45 +08:00
});
2025-01-14 15:34:07 +08:00
_closeBtn.onClick.AddListener(() =>
{
if (_isFirstEnter)
2025-01-14 15:34:07 +08:00
{
if (_clickNumber > 0)
{
UI_Manage.Instance.ClosePanel("ExplainContainPanel");
CG.UTility.PopUpMng._TriAble = true;
firstCloseCallBack?.Invoke();
2025-01-14 15:34:07 +08:00
}
else {
_trainTog.isOn = false;
_handlerTog.isOn = true;
_clickNumber++;
}
}
else
{
UI_Manage.Instance.ClosePanel("ExplainContainPanel");
CG.UTility.PopUpMng._TriAble = true;
}
});
_trainTog.isOn = true;
2025-01-02 12:15:45 +08:00
_handlerTog.isOn = false;
}
}
}