1
\$\begingroup\$

When Dropdown is placed inside a panel with ContentSizeFitter/LayoutGroup with preferred size set, it appears to take just 10x10 units, no matter what the contents are. How can I make Dropdown's preferred size adhere size of its contents, i.e. size of its biggest option?

enter image description here

\$\endgroup\$
1
\$\begingroup\$

The option child control sizes inside the panel paired with the content size fitter seems to be a bit buggy, because it's not wrapping the contents of the dropdown recursively.

I tested a couple times, and i think you should either Disable the option from the panel object:

enter image description here

OR

use a script and set the DROPDOWN OBJECT Width+Height yourself, using a layout Element componnent;

enter image description here

OR (workaround without using scripts)

  • Turn off 'Child control Size'
  • Remove/Readd dropdown
  • Add layout Element component to Dropdown
  • Click Preferred Width , Preferred Height
  • Re-enable 'Childcontrol Size' if its nescessary for your needs;
\$\endgroup\$
2
  • \$\begingroup\$ How do I determine the correct explicit sizes when the options are generated dynamically (before level starts)? \$\endgroup\$ – wondra Jun 20 '17 at 10:22
  • \$\begingroup\$ You need the panel to wrap around the dropdown options, or the dropdown button itself? Because the dropdown options should actually appear above everything else, and not interfere with other layout elements. Can you edit your question and add a mockup of what you want to do? \$\endgroup\$ – Guilherme Junqueira Coutinho Jun 20 '17 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.