Last active
November 9, 2019 18:10
-
-
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.
This file contains 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
// 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