_EmissionColor and Shader variants

Bug, maybe? I am using Universal Render Pipeline, URP, and the shader “Universal Render Pipeline/Lit” shader.
When I try to change the color with name “_EmissionColor” from script (.SetColor(“_EmissionColor”, color);), nothing happens.
That is: Nothing happens unless the color has already been set “a little” directly in the Inspector UI. And I do know why, I think: “Shader Variants”. So, unless the color is set “slightly” (Or “a lot”, but just “set”) beforehand, it is using a variant without this property. Or, the property is there (Or I would get an error), but is not doing anything. And it make sense. We only want to use shader variants that do the minimal amount of work needed, of course.
But… going around on all materials and setting the color “Slightly”, just to be able to use the color from script, seem… a bug? Is this expected behavior? I know the Shader Variant that actually does take _EmissionColor into account is compiled and ready, because other objects use it (And works fine with the scripting). So shouldn’t the very SetColor(“_EmissionColor”, color) make sure to set the right variant for the material? I mean, this is only something I “understand” because of many years and a broad overview of the internals of Unity. A beginner would have NO clue why he is told in the docs of certain scripting features, and then it doesn’t do anything.
Is there a way I don’t know about to enforce a certain variant? I have never had this problem before with the ordinary render pipeline, and not very used to these scriptable pipelines, so may be I misunderstand something here…
I also tried to make a copy of the shader, and change the line “[HDR] _EmissionColor(“Color”, Color) = (1,1,1)”, so that it would initialize with a color, but couldn’t get that to happen as well. Very strange… Feels like I really need to change it in UI before Unity want to change variant to a version, that uses the color.

up

I agree. black Emission colour with Emission checkbox enabled shouldn’t strip emission from the shader. Or at least it should display some warning to disable emission checkbox

I am agree, this is a bad behavior. But found a workaround for this - not neat and clean, but… Create a dummy material with Emission enabled and some value for it is set - it can be just white color (255, 255, 255).

You don’t need to use this material somewhere, it should be only presented in the build as a resource (works with addressables too). The bad side - this dummy material with emission enabled should be created for every shader variant you require. The variants differentiates by enabled shader keywords I think, but not sure.

I’ve noticed that if you alter either the base color or the emission color in the editor whilst running in the Play tab it suddenly works, even though altering them from code does not. Clearly the editor is setting something somewhere… I tried material.EnableKeyword("_EMISSIVE"); to no avail.