using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; public class UIManager : MonoBehaviour { private static UIManager instance; private UIInteractable currentSelectedUIInteractable; private BlockData currentSelectedData; public UnityEvent onSelectEvent; private CategoryData currentCategory; private void Awake() { if (instance == null) instance = this; else Destroy(this.gameObject); } public static UIManager getInstance() => instance; // Selection public void selectUIInteractable(UIInteractable uiInteractable) { if (currentSelectedUIInteractable != null) currentSelectedUIInteractable.onSelectExit(); currentSelectedUIInteractable = uiInteractable; currentSelectedData = uiInteractable.getAssociatedBlockData(); onSelectEvent.Invoke(currentSelectedData); } public void deselectUIInteractable() { if (currentSelectedUIInteractable != null) currentSelectedUIInteractable.onSelectExit(); currentSelectedUIInteractable = null; currentSelectedData = null; } }