public void Call(object buttonId) { List <Action> callbacks = callbackMap.GetSlot(buttonMap.Get(buttonId.ToText())); if (callbacks != null) { foreach (Action a in callbacks) { a.Call(); } } }
private void GetWWW(string url, bool dispose, Action <WWW> callback) { callbacks.Add(url, callback); if (callbacks.GetCount(url) > 1) { return; } Threading.inst.StartCoroutine(GetWWWCo(url, dispose, www => { List <Action <WWW> > slot = callbacks.GetSlot(url); callbacks.Remove(url); slot.ForEach(s => s(www)); })); }
public void GetAsset <T>(string alias, string url, Action <T> callback, bool asyncHint = false) where T : Object { VerifyUrl(url); if (!url.IsEmpty()) { T o = assetCache.Get(url) as T; if (o != null) { callback(o); } else { callbacks.Add(url, callback); if (callbacks.GetCount(url) == 1) { log.Debug("Loading {0}", url); loader.GetAsset <T>(pathConverter(url), a => { if (a != null) { AddToCache(alias, url, a); } List <Delegate> slot = callbacks.GetSlot(url); callbacks.Remove(url); foreach (Delegate c in slot) { ((Action <T>)c)(a); } }, asyncHint); } } } else { callback(null); } }
private void GetWWW(string url, bool dispose, Action <WWW> callback) { callbacks.Add(url, callback); if (callbacks.GetCount(url) > 1) { return; } GetFileCache(url, f => { if (f != null) { Threading.inst.StartCoroutine(LoadWWWAsync(f, dispose, www => { List <Action <WWW> > slot = callbacks.GetSlot(url); callbacks.Remove(url); slot.ForEach(s => s(www)); })); } else { List <Action <WWW> > slot = callbacks.GetSlot(url); callbacks.Remove(url); slot.ForEach(s => s(null)); } }); }