Search Unity

Show Material Presets in a Custom Inspector

Discussion in 'UGUI & TextMesh Pro' started by jcuriel_glu, Oct 25, 2018.

  1. jcuriel_glu

    jcuriel_glu

    Joined:
    May 26, 2017
    Posts:
    16
    I've searched for a way to show a font's material presets in a custom inspector, but have been unable to find a solution. Anyone ever try implementing this before? I would look at the TextMeshPro editor scripts, but can't seem to find them anywhere.

    Thanks!
     
  2. jcuriel_glu

    jcuriel_glu

    Joined:
    May 26, 2017
    Posts:
    16
    Well, I was able to find the source now that I figured out where the Package Manager's packages folder is.
    On Mac: /Users/username/Library/Unity/cache/packages

    Will look in here to see if I can find an answer, but if you have one, please post!
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Can you provide more insight on the use case for this inspector?

    Currently, TMP identifies the material presets for a given font asset based on the name of the material (to narrow down the potential list) and then by looking at the texture referenced by these materials.
     
  4. jcuriel_glu

    jcuriel_glu

    Joined:
    May 26, 2017
    Posts:
    16
    @Stephan_B Sorry for the late reply. In my case, taking inspiration from a live training (Customizing UI with Scriptable Objects) https://unity3d.com/learn/tutorials/topics/user-interface-ui/introduction?playlist=17111

    I'm creating a custom inspector for a scriptable object which will set the font asset and material preset along with other text properties for any TextMeshPro object that uses that scriptable object.

    Looking through the source of TextMeshPro editor scripts I was able to create something like this (see image attached).
     

    Attached Files: