/// <summary> /// Gives resource to the caller, frees up resources /// </summary> /// <param name="id"></param> private static void GiveResourceToCaller(ulong id) { Object resource = preloadedResources[id]; IResourceRequestor requestor = requestorsQueue[id]; requestor.ProcessLoadedResources(resource); Instance.StartCoroutine(FreeUpResourceE(requestor, id)); }
/// <summary> /// Frees use resources from callers and preloads, resets caller state /// </summary> /// <param name="requestor"></param> /// <param name="id"></param> /// <returns></returns> private static IEnumerator FreeUpResourceE(IResourceRequestor requestor, ulong id) { while (requestor.IsResourcesObtained()) { yield return(null); } requestor.ResetState(); preloadedResources.Remove(id); requestorsQueue.Remove(id); }
/// <summary> /// Async reousrce preload call /// </summary> /// <param name="path"></param> /// <param name="caller"></param> public static void LoadResourceAsync(string path, IResourceRequestor caller) { requestorsQueue.Add(callCount, caller); Instance.StartCoroutine(LoadResourceAsyncE(path, callCount)); callCount++; }