How to programmatically change the Material used in a Text Mesh Pro component to a Material Preset

I added a Text Mesh Pro component to a GameObject, and applied a font, KGRHMain.

8945151--1227411--jRQYK.png

I would like to programatically change the Material used in the Mesh Renderer, from the default material to KGRHMain Shadows.

8945151--1227408--hFzxX.png

When I do this manually, I get exactly the result that I want. But when I try doing this programatically, the Material used in the Mesh Renderer doesn’t change.
8945151--1227405--HsG9g.png I’ve tried many variations, but can’t get it to work. I think I’m lacking some conceptual understanding of how to change Materials using Material Presets.

How can I change the Material in the Mesh Renderer to use the Material Preset that I want? (KGRHMain Shadows)

1 Like

Ah ok, I see now… I can ignore the Mesh Renderer component and just use the Text Mesh Pro component.