I'm relatively new to programming in general, and I'm learning C# and using it in Unity3D for game development, and I have a question about if possible, how to avoid NullReferenceExceptions in an if statement when asking if a variable is equal to something when the variable is null.
I have this if statement that checks if the gameObject that a raycast hit is equal to a certain name, and if you are to press out into the void of the skybox that object will of course return null, and this causes a NullReferenceException.
I just want to know, is it even worth trying to avoid even though it doesn't affect anything at all, it's just a bit disturbing to me, XD.
This is the if statement,
if (Input.GetButtonDown ("Fire1") && rayhit.transform.name == "Reflector")
{
}