Initial commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user