init
This commit is contained in:
42
Assets/Scripts/Event/EventManager.cs
Normal file
42
Assets/Scripts/Event/EventManager.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Event.EventArgs;
|
||||
using Event.EventHandler;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Event
|
||||
{
|
||||
public class EventManager : MonoBehaviour
|
||||
{
|
||||
private static EventManager _instance;
|
||||
|
||||
public static EventManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance)
|
||||
return _instance;
|
||||
_instance = FindObjectOfType<EventManager>() ??
|
||||
new GameObject("EventManager").AddComponent<EventManager>();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (_instance != null && _instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
public event CameraInterActHandler CameraInterAct;
|
||||
|
||||
public void OnCameraInterAct(GameObject item)
|
||||
{
|
||||
CameraInterAct?.Invoke(new CameraInterActArgs(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user