static int LoadAudioClipBundleAsync(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); string arg0 = ToLua.CheckString(L, 1); string arg1 = ToLua.CheckString(L, 2); RSG.IPromise <UnityEngine.AudioClip> o = AL.Resources.ResourceManager.LoadAudioClipBundleAsync(arg0, arg1); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void BlockUntil(RSG.IPromise promise) { this.WaitUntilReady().Then(() => { this.asyncReadyPromise = promise; this.isReady = false; this.lastReadyCallbackTime = Time.time; promise.Finally(() => { if (this.asyncReadyPromise != promise) { return; // we were aborted?! } this.isReady = false; this.readyTime = Time.time + this.Wait; this.asyncReadyPromise = null; this.Update(); }).Done(); }); }
} //return Time.time >= this.readyTime; }} void Update() { if (!this.isReady) { if (this.asyncReadyPromise != null) { if (Time.time >= this.lastReadyCallbackTime + this.ReadyCallbackTimeout) { // abort callback this.asyncReadyPromise = null; this.isReady = true; } } else { this.isReady = (Time.time >= this.readyTime); } } if (this.queue.Count > 0 && this.isReady) { if (this.Verbose) { Debug.Log("[AsyncQueue.Update] next item"); } this.isReady = false; this.readyTime = Time.time + this.Wait; var item = this.queue.Dequeue(); #if UNITY_EDITOR this.DebugInfo.Count = this.queue.Count; #endif item.Invoke(); } #if UNITY_EDITOR this.DebugInfo.IsReady = this.isReady; #endif }
public RSG.IPromise WhenReady(System.Func <RSG.IPromise> func) { return(this.WaitUntilReady().Then(() => { var promise = func.Invoke(); this.asyncReadyPromise = promise; this.isReady = false; this.lastReadyCallbackTime = Time.time; this.asyncReadyPromise.Finally(() => { if (this.asyncReadyPromise != promise) { return; // we were aborted?! } this.isReady = false; this.readyTime = Time.time + this.Wait; this.asyncReadyPromise = null; this.Update(); }); })); }