IndieGame/client/Assets/Ether/Scripts/Module/Extension/UGUI/Toggle/ToggleEx.cs

43 lines
866 B
C#
Raw Normal View History

2024-10-18 18:30:22 +08:00
using Sirenix.OdinInspector;
2024-10-18 01:17:48 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2024-10-18 18:30:22 +08:00
using UnityEngine.EventSystems;
2024-10-18 01:17:48 +08:00
namespace Ether
{
2024-10-18 18:30:22 +08:00
public class ToggleEx : MonoBehaviour, IPointerClickHandler
{
[LabelText("选择状态显示")]
public GameObject checkRoot;
2024-10-18 01:17:48 +08:00
2024-10-18 18:30:22 +08:00
[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);
}
}
2024-10-18 01:17:48 +08:00
}