It might seem like a good idea to valid-check, but it could actually make troubleshooting much more difficult.
To elaborate, here’s a small example. You spawn Something - an object with no visual components to it, and later you want to DoThing() with it. But for whatever reason, Something didn’t spawn.
If you don’t valid check Something before DoThing()
then the game will crash or you’ll get a warning in the editor. This information points to where the problem is. You know that something is wrong and in broad terms what needs fixing.
If you valid check Something before DoThing()
then the check will fail silently and you have no idea why DoThing() didn’t do its thing.
Is it DoThing() that is the problem? Is Something the problem? Where’s the issue occuring? Maybe you don’t even realize it has to do with Something or DoThing() and start looking elsewhere for the cause of the issue.
If you’re getting errors, something is wrong. They should not happen in the first place. But an IsValid() check is not a solution.
IsValid() should be put in with thought, only for things that are allowed to fail silently.