Highlight staying active after raycast leaves collider

So I am attempting to make a scientific program where a person using an Oculus rift headset looks around a detector and a raycast is continuously emitting from a crosshair in their field of view that I have attached a script to. The script calls up little UI canvases that give information about the detector. I am attempting to have the script also highlight the object that is being looked at while the canvas is visible. When the raycast contacts the collider the canvas on the gameobject is revealed and the material is set to a highlight material, this all works fine. However, when you look away from the gameobject and the raycast is no longer looking at the collider the informational canvas is no longer visible but the object still has the material set to highlight. Below is my code the console moment from when the highlight is first applied. As you can see the highlight is not applied when it should but rather after it should be and the material is never set back to the original. Any help would be much appreciated.

Second Edit: So for the sake of time saving on my project I have opted for a highlight script that is attached to each object that needs to be highlighted. I will revisit this solution later but for now ill share the code I used to make the highlight. all public variables are defined in the editor
74705-highlightcodeshot.png