Search Unity

One font asset with different materials

Discussion in 'UGUI & TextMesh Pro' started by mahdiii, Dec 29, 2018.

  1. mahdiii

    mahdiii

    Joined:
    Oct 30, 2014
    Posts:
    856
    Hi. I have only one font asset and would like to have several materials.
    How can I handle it?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Material Presets allow you to create different materials / visual variations for any given font asset. Please take the time to watch the following video which covers this functionality.

     
  3. mahdiii

    mahdiii

    Joined:
    Oct 30, 2014
    Posts:
    856
    Thanks. I do not want to create materials for each of them. Yes I saw it before.
    He pressed right click and select create material Presets.
    I have already found it. I changed inspector mode from normal to debug and assigned an arbitrary material to shared material slot.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Whatever material you use with the Font Asset has to be using the appropriate shader (TMP SDF or Bitmap) and such material also has to reference the appropriate Atlas Texture for the given font asset which is what happens when you create material presets.

    Materials Presets are very efficient so if you are trying to get different visual styles for your text objects, that is the way to go. What are you trying to achieve?
     
  5. mahdiii

    mahdiii

    Joined:
    Oct 30, 2014
    Posts:
    856
    Yes. I just apply one font asset but want to have different styles.
    When I click on right mouse button and select "create material preset", it creates a new material, cool but I do not intend to create new materials for every text. So I change the inspector from normal to debug mode and assign the favorable material to it.
    I can drag and drop materials as well.
    Another question, If I change the material name, I can not see it in the material preset list. Also, I do not see a "duplicate" option when I click on right mouse button.
    Text mesh pro is the top useful package in unity and always is on top.
     
    Last edited: Dec 29, 2018
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The idea behind Material Presets is to design / create a unique Material Preset for each visual style that you want for a given font asset.

    Many TextMesh Pro customers have like 50 to 100 different Material Presets for each font asset and this is very efficient as Material Presets are an Asset which can be shared between text objects. As such if you have a scene made up of 50 text objects with 5 different visual treatment between them (ie. using 5 material presets) you would only get 5 draw calls. Obviously this is subject to Unity's batching rules.

    Again, you only need one Material Preset per visual style per font asset. This is very efficient and avoid duplication of resources.

    In order for Material Presets to be listed in the Material Preset pull down on the text object for a given font asset, they must follow a naming convention where their name is Font Name + whatever else. So if the Font Asset is named "Arial SDF" then the presets have to be named "Arial SDF - something".

    Duplicate was renamed to "Create Material Preset" to more accurately reflect what it does.
     
    Last edited: Dec 29, 2018
    literacy and mahdiii like this.