You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using System;
|
|
|
|
|
public class EventManager : MonoSingleton<EventManager>
|
|
|
|
|
{
|
|
|
|
|
protected override void Awake()
|
|
|
|
|
{
|
|
|
|
|
base.Awake();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public delegate void m_fun(params object[] args);
|
|
|
|
|
public static m_fun fun;
|
|
|
|
|
static Dictionary<string, m_fun> Events = new Dictionary<string, m_fun>();
|
|
|
|
|
//ע<><D7A2>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ӦΪparams object[] args
|
|
|
|
|
public void register(string name, m_fun callback) {
|
|
|
|
|
if (!Events.ContainsKey(name))
|
|
|
|
|
{
|
|
|
|
|
Events.Add(name,callback);
|
|
|
|
|
Debug.Log("ע<><D7A2>"+ name);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Events[name] = callback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void emit(string name,params object[] args) {
|
|
|
|
|
if (Events.ContainsKey(name))
|
|
|
|
|
{
|
|
|
|
|
Events[name](args);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Debug.Log("û<><C3BB>"+ name + "<22>¼<EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
}
|