Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Create a custom dropdown with custom items

Discussion in 'UI Toolkit' started by spakment, Jul 28, 2022.

  1. spakment

    spakment

    Joined:
    Dec 19, 2017
    Posts:
    90
    I'm attempting to create something like this with UI Toolkit

    I'd like to create a component like the DropdownField, inherit from PopupField, and setup custom children that will accept something like a list of hex color codes in the choices field and render something like the above. On click it would return the hex color code that was selected.

    I'm struggling to find how to use uxmlChildElementsDescription and setup traits that would do this, can anyone provide an example or possible solutions?

    (I'm assuming there's someway to set the background color of each child's style inline from the value that's passed in)
     
  2. Eldamir88

    Eldamir88

    Joined:
    Jul 2, 2019
    Posts:
    12
    And here I am just trying to add some styling to the foldout of the builtin DropdownField, but that seems impossible :(