Search code examples
unity-game-enginemenudropdown

Is there any way to have a Unity TextMeshPro dropdown option with a different font than the others in the list?


I am using TextMeshPro Dropdowns in Unity as the basis for my menu system. The problem is Unity TMP Dropdowns require one option to be selected at all times, and clicking the already selected option won't trigger the "On Value Changed" function for processing the option.

Thus the only solution I am aware of is to have the first option be a dummy option like "CHOOSE:" or "SELECT ONE:" which is then the initially selected option. This is not too bad but it would be better if it was possible to at least make it a different font (for example, bold) so it looks intentional.

From what I can see however, there is no way to script or code anything to change the font size/color/face of only one option in a dropdown.

Is this possible or would there be another suggested solution to the problem?

Thanks.


Solution

  • You can use the RichText tags for setting string literals, something like

    List < string > m_DropOptions = new List < string > { "<size=19><i>Select something</i></size>", "Option 1", "Option 2" };
    

    Now Select something will be italic and with a different font size. You can always explore RichText link to find information that suite the needs of the application.

    Output:

    enter image description here