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

DropDown doesnt close after selection

Discussion in 'UGUI & TextMesh Pro' started by Homicide, Mar 2, 2018.

  1. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    Whats up with that?

    Its funny that on the scene canvas rendering, it does close, but in the real Game Rendering screen, it just hangs open after selecting it

    I did try .Hide() but maybe out of place. But still, i would have thought this was innate behaviour and it would close on selection.
     
  2. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    I guess i have voodoo unity... nobody else huh.
     
  3. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    upload_2018-3-3_12-45-15.png

    This is during runtime... The Drop Down opens, i select, and ... it stays Open like that. This is the intended design of a drop down box?
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Definitely sounds like a bug that you should report. Unless your code is doing something strange, it should close after you make a selection, of course. :)
     
    Homicide likes this.
  5. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    I don't use any code at all pertaining to that box other then adding a routine via AddListener, and then adding the new options..


    Code (CSharp):
    1.  
    2.     public void Awake()
    3.     {
    4.         GetResourcesListing();
    5.         dropDown_CellThemes.onValueChanged.AddListener(SetCellTheme);
    6.         inputFieldXLength.onValueChanged.AddListener(SetMapXLength);
    7.         inputFieldZLength.onValueChanged.AddListener(SetMapZLength);
    8.         inputFieldXZLength.onValueChanged.AddListener(SetCellXZLength);
    9.     }
    10.  
    11.     private void GetResourcesListing()
    12.     {
    13.         string currentDirectory = Directory.GetCurrentDirectory();
    14.         currentDirectory += "/Assets/Resources/Cells/";
    15.         cellDirectories = Directory.GetDirectories(currentDirectory);
    16.         dropDown_CellThemes.options.Clear();
    17.         List<string> themes = new List<string>();
    18.         int i = 0;
    19.         foreach (string s in cellDirectories)
    20.         {
    21.             string tmpA = Directory.GetCurrentDirectory() + "/Resources/Assets/Cells/" ;
    22.             Debug.Log(tmpA);
    23.             string tmpB = s.Remove(0, tmpA.Length);
    24.             themes.Add(tmpB);
    25.             i++;
    26.         }
    27.         dropDown_CellThemes.AddOptions(themes);
    28.     }
    So im pretty sure its not anything i did. Seems fairly normal,.except the way its (UI.DropDown) behaving.. But the editor is giving me grief n several fronts regarding UI it seems. As i show in this thread too. https://forum.unity.com/threads/custom-window-maxwidth-just-a-mess.520074/
     
  6. Eristen

    Eristen

    Joined:
    Jun 17, 2021
    Posts:
    17
    I am having the same situation. It seems adding an event listener via code to a dropdown somehow overrides the default behavior of closing/folding the dropdown and I have no idea how to simulate the same behaviour.

    edit:

    I found out that this behaviour happened only if I add a listener to the dropdown both via code and via the inspector. If only one of the methods is used this bug does not happen
     
    Last edited: Sep 5, 2021
    RambosRide likes this.
  7. Ikaro88

    Ikaro88

    Joined:
    Jun 6, 2016
    Posts:
    296
    any solution to close that throught code?
     
    mattiapompita and akast07 like this.
  8. C0lonnello

    C0lonnello

    Joined:
    Nov 7, 2022
    Posts:
    30
    2023 and I added a listener to OnValueChanged only through inspector and the dropdown list doesn't hide automatically.
    Do any of you guys recall a solution for this?
     
  9. nawin_gamedev

    nawin_gamedev

    Joined:
    Sep 11, 2023
    Posts:
    7
    Facing same issue, I have two dropdowns in my scene one is working perfectly but other is not closing after selection in Unity version 2023.1, is it a bug or my fault??
     
  10. SteadyBoar

    SteadyBoar

    Joined:
    Nov 3, 2020
    Posts:
    1
    Facing same issue in 2022.3.4.
    I noticed it is somehow related to canvas settings.
    Seems to be linked also to game object nesting. If game object in parent has canvas and childer canvas has dropdown it is not working fine, at least in my case.
    Having dedicated canvas, with no top canvases in hierachy seems to help. Also set Render Mode to Screen Space - Overlay and toggle Pixel Perfect.
    Maybe this will help somehow in your cases too.
     
    Last edited: Oct 28, 2023
  11. dan_dor_dm

    dan_dor_dm

    Joined:
    Mar 11, 2022
    Posts:
    1
    I had a similar problem when I transferred my UI to another project. the solution turned out to be to change the sorting layer of the main Canvas: it was in error and could not find the layer from the previous project