- Home /
this==null evaluates to true?
I have a script that is saying it cannot access itself because it is deleted. The script is still visible in the scene on its gameObject, and there are no "Missing Component"s on any of objects. Also confusing, it says itself is null?
Interesting. If I remember correctly, Unity has overridden the operator for GameObjects, so they return true when compared to null after they are destroyed.
Your case seems to be a little different, but it would be easier to help if we knew the scripts you are using. Are you using Destroy() or any cleanup on those components?
Ye, fun times when you see that (this == null) = "true" in the console window for the first time :D
This blogpost tries to explain why this happens ;)
I'm expecting you're encountering the 2nd point of that blogpost but as @ScaniX said it's easier if we knew the script you are using that is throwing the error :p