35 lines
No EOL
722 B
C#
35 lines
No EOL
722 B
C#
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using System.Collections.Generic;
|
|
|
|
public class MANAGER_EventsDialogue : MonoBehaviour
|
|
{
|
|
|
|
public static MANAGER_EventsDialogue Instance;
|
|
|
|
[System.Serializable]
|
|
public struct EventMapping
|
|
{
|
|
public string id;
|
|
public UnityEvent action;
|
|
}
|
|
|
|
public List<EventMapping> events = new List<EventMapping>();
|
|
|
|
private void Awake() => Instance = this;
|
|
|
|
public void Execute(string id)
|
|
{
|
|
if (string.IsNullOrEmpty(id)) return;
|
|
|
|
|
|
var mapping = events.Find(e => e.id == id);
|
|
if (mapping.id != null)
|
|
{
|
|
mapping.action?.Invoke();
|
|
}
|
|
else
|
|
{
|
|
}
|
|
}
|
|
} |