48 lines
1.2 KiB
C#
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;
|
|
}
|
|
|
|
} |