using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; namespace Michsky.UI.Heat { [ExecuteInEditMode] [DisallowMultipleComponent] [RequireComponent(typeof(Animator))] public class BoxButtonManager : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler, ISubmitHandler { public enum BackgroundFilter { Aqua = 0, Dawn = 1, Dusk = 2, Emerald = 3, Kylo = 4, Memory = 5, Mice = 6, Pinky = 7, Retro = 8, Rock = 9, Sunset = 10, Violet = 11, Warm = 12, Random = 13 } public Sprite buttonBackground; public Sprite buttonIcon; public string buttonTitle = "Button"; public string titleLocalizationKey; public string buttonDescription = "Description"; public string descriptionLocalizationKey; public BackgroundFilter backgroundFilter; [SerializeField] private Animator animator; [SerializeField] private CanvasGroup buttonCG; public Image backgroundObj; public Image iconObj; public TextMeshProUGUI titleObj; public TextMeshProUGUI descriptionObj; public Image filterObj; public List filters = new List(); public bool isInteractable = true; public bool enableBackground = true; public bool enableIcon; public bool enableTitle = true; public bool enableDescription = true; public bool enableFilter = true; public bool useCustomContent; public bool checkForDoubleClick = true; public bool useLocalization = true; public bool bypassUpdateOnEnable; public bool useUINavigation; public Navigation.Mode navigationMode = Navigation.Mode.Automatic; public GameObject selectOnUp; public GameObject selectOnDown; public GameObject selectOnLeft; public GameObject selectOnRight; public bool wrapAround; public bool useSounds = true; [Range(0.1f, 1f)] public float doubleClickPeriod = 0.25f; [Range(0.1f, 1f)] public float disabledOpacity = 0.5f; public UnityEvent onClick = new UnityEvent(); public UnityEvent onDoubleClick = new UnityEvent(); public UnityEvent onHover = new UnityEvent(); public UnityEvent onLeave = new UnityEvent(); public UnityEvent onSelect = new UnityEvent(); public UnityEvent onDeselect = new UnityEvent(); private bool isInitialized; private float cachedStateLength = 0.5f; private bool waitingForDoubleClickInput; private Button targetButton; private void Awake() { cachedStateLength = HeatUIInternalTools.GetAnimatorClipLength(animator, "BoxButton_Highlighted") + 0.1f; } private void OnEnable() { if (!isInitialized) { Initialize(); } if (!bypassUpdateOnEnable) { UpdateUI(); } if (EventSystem.current != null && EventSystem.current.currentSelectedGameObject == base.gameObject) { TriggerAnimation("Highlighted"); } if (Application.isPlaying && useUINavigation) { AddUINavigation(); } else if (Application.isPlaying && !useUINavigation && targetButton == null) { if (base.gameObject.GetComponent