Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Material disappears from TextMeshPro object when creating a prefab?

Discussion in 'Unity UI & TextMesh Pro' started by HEATH3N, Aug 12, 2018.

  1. HEATH3N

    HEATH3N

    Joined:
    Jul 19, 2014
    Posts:
    7
    I created a TextMeshPro text object with an outline and made it into a prefab. This caused the Material component to disappear and I'm not sure if/how I can add it back. I'm using Unity 2018.1 with TextMesh Pro 1.2.4. Thanks.
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,732
    The Material component not being shown on prefabs is normal behavior for Canvas related objects. When the prefab is instantiated, the material component will be added automatically.

    If you are trying to use a prefab to define a visual style (outline) for a given font asset, you should be using Material Presets to define visual styles for any given font asset. See the following video about Working with Material Presets.

    In this case, the text object from which you created this prefab would have your outline material preset assigned to it. When this object is instantiated, it would have the visual style defined by this material preset.
     
  3. HEATH3N

    HEATH3N

    Joined:
    Jul 19, 2014
    Posts:
    7
    So to create my outline style, I did the following:
    1. Create TextMesh object
    2. Right-click Material and choose "Create Material Preset"
    3. Adjust visual style
    4. Drag TextMesh object to folder to make it a prefab
    I am unsure how to link the material preset to this object. According to the video, it should appear in the Material Preset dropdown but I can only see the four default options there.

    EDIT: I got it working (I just forgot to hit Apply) but looking at the prefab object in the folder, there is no indication from where the style is coming from. If I delete the original object in the Hierarchy, I would have no idea how to change the style if necessary.
     
    Last edited: Aug 12, 2018
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,732
    If you look at the text object inspector, it is shows what material preset is selected.

    upload_2018-8-12_14-4-41.png

    In order for your Material Presets to be listed there, they have to include the name of the font asset. So if the font asset is named "Special Font SDF", I recommend naming your preset something like "Special Font SDF - Blue Outline" where you simply append some text to describe what this Material Preset is which is this case is "Blue Outline".

    For each visual style that you want / need for any given font asset, you create a Material Preset. You then assign these to whatever text object you want to have this visual style. Be mindful these material presets may be shared by several text objects. This means that if you modify the Material Preset, you will be modifying the visual style of all text objects using it. For each unique visual style, you create a Material Preset.
     
    HEATH3N likes this.