DropDownHelper.cs 818 B

123456789101112131415161718192021222324252627282930
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class DropDownHelper
  6. {
  7. public static void ClearDropDown(Dropdown _dropDown)
  8. {
  9. _dropDown.ClearOptions();
  10. }
  11. public static void SetDropDownItems(Dropdown _dropDown, string _name)
  12. {
  13. Dropdown.OptionData _itemData = new Dropdown.OptionData();
  14. _itemData.text = _name;
  15. _dropDown.options.Add(_itemData);
  16. }
  17. public static void SetStartName(Dropdown _dropDown, string _name)
  18. {
  19. _dropDown.captionText.text = _name;
  20. }
  21. public static void AddListener(Dropdown _dropDown, UnityEngine.Events.UnityAction<int> _action)
  22. {
  23. _dropDown.onValueChanged.RemoveAllListeners();
  24. _dropDown.onValueChanged.AddListener(_action);
  25. }
  26. }