Material SetKeyword and EnableKeyword for ComplexLit Shader Do Not Function in Unity 2021.3.2f1

SetKeyword and EnableKeyword do not appear to function properly with the Universal Render Pipeline/ComplexLit shader in Unity 2021.3.2f1. I have a Material within the Project, and I am in the Editor (so the game is not playing - I’m in Editor Mode). My code looks like this:

string inKeyword = "_CLEARCOATMAP";
LocalKeyword keyword = new LocalKeyword(materialReference.shader, inKeyword);
materialReference.EnableKeyword(keyword);
Debug.Log("--- Keyword " + inKeyword + " on material instance " + materialReference.GetInstanceID() + " is now " + materialReference.IsKeywordEnabled(inKeyword));

(Please note that the following result occurs regardless of if we use EnableKeyword or SetKeyword. The result is identical in both cases).

The debug output for this operation is:
— Keyword _CLEARCOATMAP on material instance -13860 is now True

However, when viewing the Material, the operation has actually either failed to complete, or the result was reverted, as the Debug side looks like this (note the Instance ID is indeed the same, so we’re on the correct Material instance):

And the Material Inspector itself displays this:

Could someone please advise on what I am doing wrong, or if I need to make this a formal bug report with Unity?

Thank you!

Got this to work - someone pointed out to me that EnableKeyword and SetKeyword does not actually do this for certain Keywords. ClearCoat, for example - you cannot set the keyword with these and have it be enabled. Instead you need to toggle a float to enable it, like this:

myMaterial.SetFloat(“_ClearCoat”, 1f);

This really needs to be far better documented, or the EnableKeyword path should reliably do this in all scenarios.