using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using DG.Tweening; using UnityEngine.EventSystems; using TMPro; namespace SHINT.UI { public class UI_Button : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { Image buttonBackground; Color buttonDeactiveColor; Color buttonActiveColor; bool isActive; public float dotweenAnimationDuration; public override void AfterAwake() { buttonBackground = GetComponent(); buttonDeactiveColor = new Color(42f / 255f, 48f / 255f, 66f / 255f, 1f); buttonActiveColor = new Color(255f / 255f, 99f / 255f, 23f / 255f, 1f); buttonBackground.color = buttonDeactiveColor; } public void ButtonColorChange_Active() { buttonBackground.color = buttonActiveColor; isActive = true; } public void ButtonColorChange_Deactive() { buttonBackground.color = buttonDeactiveColor; isActive = false; } void ActiveBackGround() { Color backgroundColor = buttonBackground.color; backgroundColor = buttonActiveColor; backgroundColor.a = 0.5f; buttonBackground.color = backgroundColor; } public void DeactiveBackGround() { if (isActive) return; Color backgroundColor = buttonBackground.color; backgroundColor = buttonDeactiveColor; backgroundColor.a = 1f; buttonBackground.color = backgroundColor; } public void OnPointerEnter(PointerEventData eventData) { ActiveBackGround(); } public void OnPointerExit(PointerEventData eventData) { DeactiveBackGround(); } } }