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

44 lines
1.1 KiB
C#

using UnityEngine;
using UnityEngine.EventSystems;
namespace UnityEngine.UI
{
public class ZYButton : Button
{
private Color NomalColor = Color.white;
private Text BtnText;
protected override void Awake()
{
base.Awake();
BtnText = gameObject.GetComponentInChildren<Text>();
if (BtnText != null)
NomalColor = BtnText.color;
}
public override void OnPointerClick(PointerEventData eventData)
{
if (eventData.button != PointerEventData.InputButton.Left)
return;
if (!IsActive())
return;
onClick.Invoke();
}
public override bool IsInteractable()
{
if(BtnText!=null)
{
BtnText.color = interactable ? NomalColor : GCGame.Utils.GetColorByString("515053");
}
return base.IsInteractable();
}
public string BtnName
{
get { return BtnText == null ? "" : BtnText.text; }
set { if (BtnText != null) BtnText.text = value; }
}
}
}