Creating a TMPro UI material from a TMPro Surface material?

Hey!

Is there a (convenient) way to create a new material for a TMP UI element, using a TMP Surface element’s material as a base? I’ve tried creating a new material with a (hard-coded) reference to the desired UI shader, then using Material.CopyPropertiesFromMaterial, but this mostly resulted in a ton of errors in the log about certain properties not existing in either material.
Does manually copying over the right properties even work? Or is that actually not the way to go with TMP Materials and presets?

The easiest way to create new material presets in the Editor is to simply use the context menu created for that purpose as seen below.

The process is pretty simple.

  1. Select the text object.
  2. Right click on the material inspector to bring up the context menu.
  3. Select Create Material Preset.
  4. New material will be created and automatically assigned to the text object. It will also be pinged in the project tab so you can rename it if desired.

The following video (although old now) covers this process although the context menu option was renamed in subsequent releases.

2 Likes

I know about this, but I’m looking at creating these new materials at runtime through code.
I used a workaround instead, turns out the standard TMP Materials work well enough both in UI as well as in world elements, making a “material conversion” unnecessary.

Side question, is it intentional that Surface TMP shaders aren’t supported in URP? All other shaders seem to work fine, but Surface TMP materials result in lovely magenta squares.

Surface shaders are not compatible with SRP. This is not specific to TMP but to all Surface Shaders.

The latest release of TMP includes new SRP shaders. These include Unlit and Lit URP and HDRP shaders.

The latest release is version 3.2.0-pre.3 available for Unity 2020.3 or newer.