Odd script/editor interactions? Code only works with materials open in inspector

I have some code that is only working when a material being accessed by the code is open in the editor inspector window.

I have copied some script to flash a sensor from one project that I have, that works nicely, to a different project and I get strange behavior. I flash the sensor by changing its color and emission color. Emission on the material is enabled in the inspector before running. The color is flashing fine, but the emission is not working. In the inspector I can see the material color changing, but the material is collapsed so I can’t see if the emission is still enabled (it should be) or if the color changing. Here is the odd part- If I simply expand the material in the inspector so that I can see the emission color and whether it is changing as the code says it should, then the emission in the flashing suddenly starts working correctly. In my other project I’m not having this issue.

*edit-
When the game is started the sensor is an active game object. “on” is simply a toggle to trigger the flash code in the update.

If I start the game and, in the game, toggle the sensor “on” color flashes, but emission does not work. If I select the object and expand its materials in the editor, while it is flashing, the emission begins to work. Collapsing the materials does not stop the emission, it continues as it should.

If I select the object and expand the materials in the editor before the sensor is turned on turning it on flashes color but does not emit. The color next to the checked Emission check box is flashing, but the object in the game is not. Expanding and collapsing the materials does not matter. However, toggling Emission from on to off and back on does get the object in the game to emit.

For what it’s worth, the code is below. Using the standard shader.

               current_color = Color.Lerp(original_color, flash_color, color_mult);
                sensor_renderer.material.SetColor("_Color", current_color);
                sensor_renderer.material.SetColor("_EmissionColor", current_color);
                sensor_renderer.material.EnableKeyword("_Emission");  //same with or without this line.

same problem :c