using System.Collections; using UnityEngine; using UnityEngine.Events; using UnityEngine.EventSystems; using UnityEngine.UI; namespace Michsky.UI.Heat { [DisallowMultipleComponent] public class SettingsElement : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler, ISubmitHandler { // Resources [SerializeField] private CanvasGroup highlightCG; // Settings public bool isInteractable = true; public bool useSounds = true; [Range(1, 15)] public float fadingMultiplier = 8; public bool useUINavigation = false; public Navigation.Mode navigationMode = Navigation.Mode.Automatic; public GameObject selectOnUp; public GameObject selectOnDown; public GameObject selectOnLeft; public GameObject selectOnRight; public bool wrapAround = false; // Events public UnityEvent onClick = new UnityEvent(); public UnityEvent onHover = new UnityEvent(); public UnityEvent onLeave = new UnityEvent(); // Helpers Button targetButton; void Start() { if (ControllerManager.instance != null) { ControllerManager.instance.settingsElements.Add(this); } if (UIManagerAudio.instance == null) { useSounds = false; } if (highlightCG == null) { highlightCG = new GameObject().AddComponent(); highlightCG.gameObject.AddComponent(); highlightCG.transform.SetParent(transform); highlightCG.gameObject.name = "Highlight"; } if (GetComponent() == null) { Image raycastImg = gameObject.AddComponent(); raycastImg.color = new Color(0, 0, 0, 0); raycastImg.raycastTarget = true; } } void OnEnable() { if (highlightCG != null) { highlightCG.alpha = 0; } if (Application.isPlaying && useUINavigation) { AddUINavigation(); } else if (Application.isPlaying && !useUINavigation && targetButton == null) { targetButton = gameObject.AddComponent