Created
September 16, 2019 13:11
-
-
Save runevision/c02dedc87fb1b69e05fdc448883ea83a to your computer and use it in GitHub Desktop.
obj.IsDestroyed() method for Unity objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ObjectExtensions { | |
public static bool IsDestroyed (this UnityEngine.Object obj) { | |
// Returns true if the object has been destroyed; | |
// false if it's actually null. | |
// (You could throw a NullReferenceException instead | |
// in the latter case if you wanted.) | |
return obj == null && !ReferenceEquals (obj, null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment