Files
JJBB/Assets/Project/Script/GUI/Activity/OnTogglesSelect.cs
2024-08-23 15:49:34 +08:00

93 lines
2.1 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
using UnityEngine.Events;
using System;
public class OnTogglesSelect : MonoBehaviour {
//private OnTogglesSelect Instance;
//public OnTogglesSelect GteInstance()
//{
// return Instance;
//}
//private void Awake()
//{
// Instance = this;
//}
//private void OnDestroy()
//{
// Instance = null;
//}
//public enum Acticity_Type
//{
// ACTIVITY_INVALID = -1,
// ACTIVITY_DAILY = 0, //全部任务
// ACTIVITY_EXP = 1, //经验
// ACTIVITY_LITMITTIME = 2, //限时
// ACTIVITY_EQUIP = 3, //装备
// ACTIVITY_TRIBUTE = 4, //帮贡
//}
[SerializeField]
public List<Toggle> m_Toggles = new List<Toggle>();
[SerializeField]
public ToggleGroup m_ToggleGroup;
//public Acticity_Type m_ActivityType = Acticity_Type.ACTIVITY_INVALID;
[Serializable]
public class ToggleSelect : UnityEvent<int>
{
public ToggleSelect() { } //指定一个方法 用于回调
}
[SerializeField]
public ToggleSelect m_ToggleSelectCallBack; //用于打开toggle之后打开并刷新对应的任务
//记录开启的Toggle的下标
private int lastIndex = -1;
public void OnToggleOn(bool isOn)
{
if (!isOn)
return;
for(int index = 0; index < m_Toggles.Count; index ++)
{
if (m_Toggles[index].isOn)
{
if (index < 0)
{
return;
}
if(lastIndex == index)
{
return;
}
lastIndex = index;
//刷新页面
if (m_ToggleSelectCallBack != null)
{
m_ToggleSelectCallBack.Invoke(index); //方法回调(打开对应的Togle之后会传递对应的Index值在ActivityController中做处理)
}
}
}
}
}