Files
JuegoSim/Assets/_Project/Scripts/Code/InteractionLayer/Managers/UIManager.cs
T
2026-07-21 08:56:10 +03:00

48 lines
1.2 KiB
C#

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<BlockData> 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;
}
}