How to set the scalar parameter value of a material being used in a CommonUI Style from a CommonUI button?

Hello,

I am having some difficulties trying to set the scalar parameter value of a material instance to access a texture atlas within the material. The material is applied within a CommonUI Button Style asset, whch is then applied on a CommonUI Button Widget that I use for user interface buttons with icons. It’s my intention to use the texture atlas to reference user interface icons in a performant manner rather than having something like a Common Lazy Image Component in the button with a variable to hold the individual texture file for each required icon in each button instance.

In the above photo you can see the Master Material setup, which correctly selects one texture within the texture atlas based on a scalar parameter in a user interface domain material.

In the above photo, I can correctly select each element within the texture atlas from a material instance through the value of the scalar parameter.

In the above photo, I have created a new style for testing purposes and have assigned the material instance to each of the buttons normal states. I have assigned this style to the CommonUI button I am using.


In the above photo, I am running this execution line off of “Event Pre Construct“ so that I can edit the value of the scalar parameter per button instance via the “Material Texture Atlas“ public float variable to select which icon will be taken from the texture atlas in the material to be used as the icon within the button. In this case, I am only targeting the CommonUI Styles “Normal“ state, but I’m aiming to support the other states as well so that icons can be set per button state within each button instance as well.

When I edit the value of the “Material Texture Atlas“ public float variable I do not see any changes in the icon, it does not appear to update to a new texture from within the texture atlas. I would really appreciate some help and assistance with this issue, thank you very much in advance for your time and help!

Check if you are calling SetScalarParameterValue() of your DynamicMaterialInstance after you change the value of the MaterialTextureAtlas float.

If you are, check if your Position (Atlas) parameter works in the shader for the values you are trying in the MaterialTextureAtlas