DropdownSample.cs 507 B

12345678910111213141516171819
  1. using TMPro;
  2. using UnityEngine;
  3. public class DropdownSample: MonoBehaviour
  4. {
  5. [SerializeField]
  6. private TextMeshProUGUI text = null;
  7. [SerializeField]
  8. private TMP_Dropdown dropdownWithoutPlaceholder = null;
  9. [SerializeField]
  10. private TMP_Dropdown dropdownWithPlaceholder = null;
  11. public void OnButtonClick()
  12. {
  13. text.text = dropdownWithPlaceholder.value > -1 ? "Selected values:\n" + dropdownWithoutPlaceholder.value + " - " + dropdownWithPlaceholder.value : "Error: Please make a selection";
  14. }
  15. }