Unity crashes on null

My game crashes every time something is null. This is fairly tedious to debug on mobile and it is somewhat annoying to have to put null checks everywhere (and having to remember that C# stupidly does not evaluate null to false).

I’d much prefer to have nothing happen if something is null (which in many many cases is the right answer anyway). Is there an option to get this behaviour?

No, not without some huge implications on the entire stack.

Unity is good enough to override equals and == for you to return boolean. That is why you can unity objects in an if statement. You should be checking for null and not assume some behaviour based off it across the entire application. While it’s annoying, you’re developing bad coding practices. null checks are nearly free. If your application suffers from assumptions of objects existing(like you’re getting properties or invoking methods) but the object doesn’t exist, you should do the right think and at the very least catch the exception and bow out gracefully, start using try/catch/finally to isolate code blocks, you could techincally swallow the exception, but this really is bad practices as well.

In the end you should implement try catch to catch exceptions and respond correctly. You should do null checks and appropraitely adjust your out come or instruct the user if need be. You shouldn’t (though you can) try and find away around proper implementations for at least the user that has to deal with failures.