Skip to content

Instantly share code, notes, and snippets.

@keenanwoodall
Last active November 9, 2019 18:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keenanwoodall/6c5ae5785a5e86a8b87c092d86208795 to your computer and use it in GitHub Desktop.
Save keenanwoodall/6c5ae5785a5e86a8b87c092d86208795 to your computer and use it in GitHub Desktop.
Test if the equality operator for anything that derives from Unity.Object is still overridden. Just put the script in your project and press play in any scene to test.
// read this article for more info: https://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/
using UnityEngine;
public class UnityObjectOperatorOverloadTest : MonoBehaviour
{
[RuntimeInitializeOnLoadMethod]
public static void Test()
{
var gameObject = new GameObject("UnityEngine.Object Operator Overload Test");
DestroyImmediate(gameObject);
Debug.Log($"Native object {(gameObject == null ? "IS" : "IS NOT")} destroyed.");
Debug.Log($"Managed object {(ReferenceEquals(gameObject, null) ? "IS" : "IS NOT")} destroyed.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment