Can't update TMP Material at runtime

Hello I’m currently trying to modify my TMP material at runtime but nothing seems to update. I search everywhere but nothing is working.

I just used the SetFloat function to the material, when I debug the value it change but it doesn’t update in game and editor mode. Here the code I use :

txt_Qty.fontMaterial.SetFloat(“Outer”, offset);

Just like accessing the .material property of a renderer returns an instance of that material in Unity, accessing the fontMaterial property of a text object returns an instance of that material. By contrast, accessing the .sharedMaterial or fontSharedMaterial will return the material which might be shared by multiple text objects.

So if you are trying to modify the material property for all text objects referencing this material, use the fontSharedMaterial otherwise use the fontMaterial.

Next you also need to make sure you modify the correct property. See the following post from the old TMP user forum.

In case you can’t access it … here is an image of it.

5093273--501842--upload_2019-10-22_1-58-16.png

Selecting one of the TMP shaders will allow you to see the name of those material properties as seen below.

5093273--501845--upload_2019-10-22_1-59-45.png

The ShaderUtilities should be use to reference those properties instead of strings as per that post from the TMP user forum.

It works ! I was not giving the right parameter to the function. I just replaced “Outer” by “_GlowOuter”.
Thanks for your advice, modify instance of material will be usefull for my project (instead of modify all the asset with the material.
Thanks you for your quick answer

To avoid allocations, you should be using the ShaderUtilities.ID_XXX function which is specific to TMP to avoid using strings for shader properties.