public void FireCallBack() { while (events.Count > 0) { DelegateGetPrefabResources <T> callback = events.Pop(); T obj = PopObject(); callback(obj, name); } }
public void PopResource <T>(string name, DelegateGetPrefabResources <T> callback) where T : UnityEngine.Object { Type type = typeof(T); ResourceFactory <T> factory; System.Object getValue; if (resourceFactory.TryGetValue(type, out getValue)) { factory = getValue as ResourceFactory <T>; } else { factory = new ResourceFactory <T>(); getValue = factory as System.Object; resourceFactory.Add(type, getValue); } if (factory != null) { factory.PopResource(name, callback); } }
public void PopResource(string name, DelegateGetPrefabResources <T> callback) { ResourceObject <T> resourceObject; if (!gameObjectResources.TryGetValue(name, out resourceObject)) { resourceObject = new ResourceObject <T>(name); gameObjectResources.Add(name, resourceObject); IEnumerator fun = Instance.AsyncLoadPrefab <T>(name, resourceObject); Instance.StartCoroutine(fun); } if (callback != null) { resourceObject.AddCallBack(callback); if (resourceObject.isDone) { resourceObject.FireCallBack(); } } }
public void AddCallBack(DelegateGetPrefabResources <T> callback) { events.Push(callback); }