HDRP emissive material control via C# scripting

I have tried this Code section(Rear lights activation) for SRP in my Car Race game and it worked completely fine. I am trying to activate Rear Light’s Material by changing its emissive properties when player pushes “s” key or “space” key.
But when I upgrade my project to HDRP, this code fails.
Anyone knows how I can alter my code to make it work. Thanks in Advance.

 private void turnLightsOn(){
        if (lightsFlag) return;
        brakeLights.SetColor("_EmmissiveColor", Color.red *5);
        lightsFlag = true;
    }  
  
    private void turnLightsOff(){
        if (!lightsFlag) return;
        brakeLights.SetColor("_EmissiveColor", Color.black);
        lightsFlag = false;
    }

Once a while getting through renderer worked for me

  • renderer.material.shader = Shader.Find(“HDRP/Lit”);
  • renderer.material.SetColor(“_EmissiveColor”, Color.red);

Is your scene a daylight scene ?
There might be a problem with exposure.
Disable all lights (especially sun) and try again.