IndieGame/client/Assets/Ether/Scripts/Module/Extension/UGUI/Toggle/ToggleEx.cs
2024-10-18 18:30:22 +08:00

43 lines
866 B
C#

using Sirenix.OdinInspector;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
namespace Ether
{
public class ToggleEx : MonoBehaviour, IPointerClickHandler
{
[LabelText("选择状态显示")]
public GameObject checkRoot;
[LabelText("非选择状态显示")]
public GameObject uncheckRoot;
[LabelText("选择状态")]
public bool isOn
{
set
{
SetIsOnState();
}
get => isOn;
}
public void OnPointerClick(PointerEventData eventData)
{
isOn = !isOn;
SetIsOnState();
}
private void SetIsOnState()
{
checkRoot.SetActive(isOn);
uncheckRoot.SetActive(!isOn);
}
}
}