Search Unity

Feature Request Make PopupField constructor not require a default value

Discussion in 'UI Toolkit' started by taylank, Oct 4, 2019.

  1. taylank

    taylank

    Joined:
    Nov 3, 2012
    Posts:
    182
    I really like PopupField but there is one thing that's constantly bugging me about it. Initializing it becomes tricky when the list it's supposed to get its values from is not yet populated. Yes, I could just initialize my list with a dummy item, but then I or the user has to remember to get rid of the dummy value once it is no longer needed.

    So how about having a constructor argument for PopupField to display a built-in dummy option (default T or something) until a real value becomes available?

    If there is another way to solve the problem, I'd love to hear that too.
     
  2. uDamian

    uDamian

    Unity Technologies

    Joined:
    Dec 11, 2017
    Posts:
    1,231
    I suggest you implement a custom control that inherits from PopupField. It's not too bad and you can still expose it to UXML for your users.
     
  3. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I also encounter this inconvenience from time to time. I'd love it if the PopupField would handle an invalid state by assigning an index of -1. In this case, the popup should simply be blank and have no options, but then I could populate the list at a later time.