Skip to content

Instantly share code, notes, and snippets.

@runevision
Created September 16, 2019 13:11
Show Gist options
  • Save runevision/c02dedc87fb1b69e05fdc448883ea83a to your computer and use it in GitHub Desktop.
Save runevision/c02dedc87fb1b69e05fdc448883ea83a to your computer and use it in GitHub Desktop.
obj.IsDestroyed() method for Unity objects
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