Hitobject? What about not hit object?

This is mainly a coding question, but I’m running into an issue. There are many functions for collision that have a “hit object” bit, but I’m trying to figure out how to do a “if you are not being hit” kind of function.

Currently, I have the player who is raycasting around and hitting blocks of fog. When the blocks get hit by a ray, they are disabled so the player can see past them. I’m doing this as a pixelated vision system. Now the issue I am running into, is how do I tell the fog blocks, if you AREN’T getting hit by a ray, become visible again. I’m mainly looking for a theory here, and not specific code, but feel free to explain it specifically if needed.

For reference, my code looks like this:

if (Physics.Raycast(ray1,out raycastHit1, visionDistance))
		{
			if (raycastHit1.collider.gameObject.tag == "fogblock")
			{
				GameObject hitObject = raycastHit1.collider.gameObject;
				if (hitObject)
				{
					hitObject.renderer.enabled = false;
					hitObject.collider.enabled = false;
				}
			}
		}

I can think of a couple ways. First you could put a script on all the fog blocks that enabled the collider and the renderer each frame. Then you could move your code above to LateUpdate(). Another way would be to keep track of the previous game object hit and reenable it first:

if (prevHitObject != null) 
{
    hitObject.renderer.enabled = true;
    hitObject.collider.enabled = true;
    prevHitObject = null;
}
if (Physics.Raycast(ray1,out raycastHit1, visionDistance))
       {
         if (raycastHit1.collider.gameObject.tag == "fogblock")
         {
          GameObject hitObject = raycastHit1.collider.gameObject;

          if (hitObject)
          {
              prevHitObject = hitObject;
              hitObject.renderer.enabled = false;
              hitObject.collider.enabled = false;
          }
         }
       }

If a fog bank starts visible then once a fog bank is hit then you can invoke a function that will make it visible again. This way all fog banks will be visible n seconds after you’ve last hit one.

In the case that you want every object with the tag “fogblock” to become visible again:

I would create a variable that is assigned to the returned array of GameObject.FindObjectsWithTag(“fogblock”). Then, once a ray hits a fogblock, loop through the array and all of the objects within the array that are not the hit object from the raycast will become visible.

GameObject[] fogBlocks = GameObject.FindObjectsWithTag("fogblock");

if (Physics.Raycast(ray1,out raycastHit1, visionDistance))
{
    if (raycastHit1.collider.gameObject.tag == "fogblock")
    {
        GameObject hitObject = raycastHit1.collider.gameObject;
        if (hitObject)
        {
            hitObject.renderer.enabled = false;
            hitObject.collider.enabled = false;
            for (var i = 0; i < fogBlocks.length; i++)
            {
                if (fogBlocks *!= hitObject)*

{
fogBlocks*.renderer.enabled = true;*
fogBlocks*.collider.enabled = true;*
}
}
}
}
}
@robertbu suggested to create a variable associated with the last fogblock that was hit. This is also a good method;
My method is slower and less efficient however, you have access to every individual fogblock using the array.
His method is much faster and more efficient but, you do not have access to each fogblock.