Search Unity

Setting TMP_Dropdown value through a script

Discussion in 'UGUI & TextMesh Pro' started by jnbbender, May 17, 2020.

  1. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    I am trying to populate my TM drop down menus with the data in my ScriptableObject. As simple as this question may be, I still haven't found an answer.
    This is what I think is the best I have. I tried using numeric values, etc.

    Code (CSharp):
    1. // tmText is TM_Text, the dropdown label
    2. // tmDrop is TM_Dropdown, the actual drop down
    3.  
    4.         PreferenceSettings settings = GameController.Controller.GetSettings();
    5.  
    6.         if (settings.textureQuality == Quality.LOW)
    7.         {
    8.             tmText.SetText("LOW");
    9.             tmDrop.captionText = tmText;
    10.         }
    11.         else if (settings.textureQuality == Quality.MEDIUM)
    12.         {
    13.             tmText.SetText("MEDIUM");
    14.             tmDrop.captionText = tmText;
    15.         }
    16.         else if (settings.textureQuality == Quality.HIGH)
    17.         {
    18.             tmText.SetText("HIGH");
    19.             tmDrop.captionText = tmText;
    20.         }
    21.  
    Please help