Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

PopupField - How do I assign a new list to an existing PopupField object?

Discussion in 'UI Toolkit' started by RedHillbilly, May 4, 2020.

  1. RedHillbilly

    RedHillbilly

    Joined:
    Mar 24, 2014
    Posts:
    39
    I have a popupField which I populate with a list of ScriptableObjects as such (my so is called Wave):
    Code (CSharp):
    1. PopupField<Wave> _wavesPopupField = new PopupField<Wave>(myWaveList, 0,
    2.                 new Func<Wave, string>(wave => wave.name),
    3.                 new Func<Wave, string>(wave => wave.name));
    4. rootVisualElement.Add(_wavesPopupField);
    This works perfectly fine, but I would like the elements inside the PopupField to be changed depending on other events.
    I found
    SetValueWithoutNotify
    which allows me to add items to the field, but I can't figure out how to remove (all) items, or even replace all elements with a new list.

    Is there any way to do this?

    Thanks :)