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

Changing size of dropdown in unity

Discussion in 'UGUI & TextMesh Pro' started by Berir, Jun 23, 2016.

  1. Berir

    Berir

    Joined:
    Mar 23, 2013
    Posts:
    55
    dropdawn2.jpg Hey Guys ,
    I am having troubles with setting up larger size of dropdown...

    as you can see the standard size of dropdown is 160 x 30 so when you click on the dropdown arrow the 3 options below (A B and C) are same size as above and all have same font size ...

    But I need to use Larger size of dropdown, so when I increase the size of it to 320 x 60, and change the font size to 5O... the change does not affect the 3 options below , A B C still have original size of 160 x 30 and original font size which is now way too small ...

    how do I change this please thanks ... I tried everything

    I also noticed that some setting for those 3 dropped downs options don't appear in inspector till you hit play

    Thanks in advance

    Beri
     
    BadSeedProductions and aesparza like this.
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    DropDown has a template in it. If you look at the object when you add it to the scene, it has children. Expand it and you'll see the Template child.

    Then go Template -> Viewport -> content ->Item -> Item Label
    Item Label is where you can change the size of your dropdown objects
     
  3. Zaflis

    Zaflis

    Joined:
    May 26, 2014
    Posts:
    438
    dropdown.jpg
    To do this, i changed
    - Dropdown > Template > Viewport > Content : Height 50
    - Dropdown > Template > Viewport > Content > Item : Height 50,
    - Dropdown > Template > Viewport > Content > Item > Item Label : Font size 24, bold, italic, Vertical Overflow

    (Actually Vertical Overflow should be set to Overflow on every Label in every UI... Why would they ever want to hide the text? There's a separate mask for that.)
     
    HayalOrtak, A_Marraff, Gajef and 28 others like this.
  4. Berir

    Berir

    Joined:
    Mar 23, 2013
    Posts:
    55
    Thank you that worked but I don't get as nice result as you do... even with your settings option A is a bit too high and option C is too close to the bottom almost getting out of the frame
     
  5. TheOtherJoJo

    TheOtherJoJo

    Joined:
    Apr 5, 2015
    Posts:
    14
    Thanks. Zaflis.
     
  6. playerduoberk

    playerduoberk

    Joined:
    Feb 8, 2017
    Posts:
    2
    Perfect solution. Thank you so much!
     
    cjcleveland08 and tokar_dev like this.
  7. ananthn

    ananthn

    Joined:
    May 7, 2019
    Posts:
    2
    nice one. About to write similiar wuery on this. Thanks a lot...
     
  8. lslu

    lslu

    Joined:
    Sep 7, 2019
    Posts:
    12
    Thank you! Very nice
     
  9. tim44

    tim44

    Joined:
    May 15, 2019
    Posts:
    58
    Another one to look at:
    Dropdown > Template : Height 400
     
    Last edited: Jan 9, 2021
    pturow, Ziplock9000 and nypehb like this.
  10. Elidrin

    Elidrin

    Joined:
    Nov 4, 2021
    Posts:
    6
    Over 5 years old and still great advice!
     
  11. dnoiszewski

    dnoiszewski

    Joined:
    May 16, 2020
    Posts:
    1
    Thanks Zafis. Unity 2021.1.16 and you are the only one saver
     
  12. Mr-Citizen

    Mr-Citizen

    Joined:
    Feb 20, 2021
    Posts:
    6
    How would you do this in a script? I generate the members of the dropdown list in my script, so I need to also set these values in my script.
     
  13. Zaflis

    Zaflis

    Joined:
    May 26, 2014
    Posts:
    438
    There shouldn't be an issue accessing those object properties in script. At the top you should add:
    Code (CSharp):
    1. using UnityEngine.UI;
    One example:
    Code (CSharp):
    1. listitem.GetComponent<Text>().text = "Hello world";
    Other than that we might need to know more about the case. Digging deeper into sub-objects sometimes takes a little bit of effort... But even prefabs may be able to auto-fill some reference variables.
     
  14. n2oukdnb

    n2oukdnb

    Joined:
    Aug 28, 2022
    Posts:
    3
    Thank you still 6 years later :)
     
  15. cheeseman_lives

    cheeseman_lives

    Joined:
    Mar 8, 2023
    Posts:
    2
  16. Liam_kng

    Liam_kng

    Joined:
    Jul 18, 2022
    Posts:
    1
    You have probably figured out what the Problem was, but to anyone having the same issue:
    Make sure, that both height values
    • Dropdown > Template > Viewport > Content : Height X
    • Dropdown > Template > Viewport > Content > Item : Height X
    are set to the same value.
     
    akhirrashad and CitrioN like this.