Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it 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. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    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

Show Material Presets in a Custom Inspector

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

  1. jcuriel_glu

    jcuriel_glu

    Joined:
    May 26, 2017
    Posts:
    9
    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:
    9
    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

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,773
    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:
    9
    @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: