/// <summary> /// Uses Unity Fake Null /// https://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/ /// https://forum.unity.com/threads/fun-with-null.148090/ /// </summary> private void TestObject(object obj) { // An object is a zombie if: // // * It is not actually null. // * It is a subclass of UnityEngine.Object // * It compares itself as equal to null. // bool exists = obj != null; // Comparing a System.object. "Fake null" doesn't get a chance to run here. bool isUnityObj = obj is UnityEngine.Object; UnityEngine.Object unityObj = obj as UnityEngine.Object; bool zombie = exists && isUnityObj && (unityObj == null); ++NumTestsPerformed; // Emit an event every 1024 tests. bool madeProgress = (NumTestsPerformed & 0x3ff) == 0; if (madeProgress) { MadeProgress?.Invoke(); } if (zombie) { ZombieHit?.Invoke(obj); } }
public void Progress(int size) { lock (progressLock) { BytesScanned += size; MadeProgress?.Invoke(this, EventArgs.Empty); var percent = (int)Math.Min(100, Math.Max(0, 100 * ((double)BytesScanned / (double)Settings.Size))); if (percent > ProgressPercent) { ProgressPercent = percent; MadeProgressPercent?.Invoke(this, EventArgs.Empty); } } }
protected virtual void OnMadeProgress(ModelPusherProgressEventArgs e) { MadeProgress?.Invoke(this, e); }