public static void AddDestroy(UnityEngine.Object obj, float delay) { if (obj == null) { return; } if (!Application.isPlaying) { UnityEngine.Object.DestroyImmediate(obj); } else if (delay <= 0f) { UnityEngine.Object.Destroy(obj); } else { UpdateManager.CreateInstance(); UpdateManager.DestroyEntry destroyEntry = new UpdateManager.DestroyEntry() { obj = obj, time = Time.realtimeSinceStartup + delay }; UpdateManager.mInst.mDest.Add(destroyEntry); } }
private bool CoroutineUpdate() { float realtimeSinceStartup = Time.realtimeSinceStartup; float num = realtimeSinceStartup - this.mTime; if (num < 0.001f) { return(true); } this.mTime = realtimeSinceStartup; this.UpdateList(this.mOnCoro, num); bool isPlaying = Application.isPlaying; int i = this.mDest.size; while (i > 0) { UpdateManager.DestroyEntry destroyEntry = this.mDest.buffer[--i]; if (!isPlaying || destroyEntry.time < this.mTime) { if (destroyEntry.obj != null) { NGUITools.Destroy(destroyEntry.obj); destroyEntry.obj = null; } this.mDest.RemoveAt(i); } } if (this.mOnUpdate.Count == 0 && this.mOnLate.Count == 0 && this.mOnCoro.Count == 0 && this.mDest.size == 0) { NGUITools.Destroy(base.gameObject); return(false); } return(true); }
private bool CoroutineUpdate() { float single = Time.realtimeSinceStartup; float single1 = single - this.mTime; if (single1 < 0.001f) { return(true); } this.mTime = single; this.UpdateList(this.mOnCoro, single1); bool flag = Application.isPlaying; int count = this.mDest.Count; while (count > 0) { int num = count - 1; count = num; UpdateManager.DestroyEntry item = this.mDest[num]; if (flag && item.time >= this.mTime) { continue; } if (item.obj != null) { NGUITools.Destroy(item.obj); item.obj = null; } this.mDest.RemoveAt(count); } if (this.mOnUpdate.Count != 0 || this.mOnLate.Count != 0 || this.mOnCoro.Count != 0 || this.mDest.Count != 0) { return(true); } NGUITools.Destroy(base.gameObject); return(false); }