Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question tmp dropdown issues.

Discussion in 'UGUI & TextMesh Pro' started by cda1987, Oct 16, 2023.

  1. cda1987

    cda1987

    Joined:
    Oct 12, 2013
    Posts:
    2
    hello, I'm trying to use a tmp pro dropdown button, No matter if I select option B or C it still displays Option A. I've added some debug.logs to it and it's changing the value even says it's changing the Label Text. however It continues to show Option A as the main text in the drop down no matter what option you select.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using TMPro;
    5. using UnityEngine.UI;
    6.  
    7. public class ButtonManager : MonoBehaviour
    8. {
    9.  
    10.     // Main Menu
    11.     public Button startgame;
    12.     public GameObject MainMenuCanvas;
    13.  
    14.  
    15.  
    16.     // Character Creation
    17.     public TMPro.TMP_Text CharacterPreview;
    18.     public TMPro.TMP_Dropdown raceDropdown;
    19.     public TMPro.TMP_Dropdown classDropdown;
    20.     public TMPro.TMP_Dropdown ability1Dropdown;
    21.     public TMPro.TMP_Dropdown ability2Dropdown;
    22.     public TMPro.TMP_Dropdown ability3Dropdown;
    23.     public TMPro.TMP_Dropdown ability4Dropdown;
    24.     public RawImage CharacterCreateImage;
    25.     public Texture2D[] CharacterCreateImages;
    26.     public GameObject CharacterCreateCanvas;
    27.     public GameObject ClassEnable;
    28.     public GameObject Ability1Enable;
    29.     public GameObject ImageEnable;
    30.     public GameObject StatpreviewEnable;
    31.     // Start is called before the first frame update
    32.     void Start()
    33.     {
    34.        
    35.     }
    36.  
    37.     // Update is called once per frame
    38.     void Update()
    39.     {
    40.        
    41.     }
    42.  
    43.     public void ToggleCharacterCreateCanvas()
    44.     {
    45.         // If the canvas is active, disable it. Otherwise, enable it.
    46.         bool isActive = CharacterCreateCanvas.activeSelf;
    47.         CharacterCreateCanvas.SetActive(!isActive);
    48.         bool active = MainMenuCanvas.activeSelf;
    49.         MainMenuCanvas.SetActive(!active);
    50.     }
    51. }
    52.  

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using TMPro;
    5.  
    6. public class CharacterCreatorUI : MonoBehaviour
    7. {
    8.     public ButtonManager mybuttons;
    9.     void Start()
    10.     {
    11.  
    12.     }
    13.     void Update()
    14.     {
    15.         PopulateDropdown();
    16.     }
    17.  
    18.     private void PopulateDropdown()
    19.     {
    20.         string[] races = BaseRace.GetAllRaces();
    21.  
    22.         mybuttons.raceDropdown.ClearOptions();
    23.         List<string> raceList = new List<string>(races);
    24.         mybuttons.raceDropdown.AddOptions(raceList);
    25.     }
    26. }
    upload_2023-10-15_21-12-12.png
    upload_2023-10-15_21-13-33.png
    upload_2023-10-15_21-13-54.png

    any ideas what I am doing wrong?
    thanks for helping.
     

    Attached Files: