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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Can't get a simple drop-down menu to work

Discussion in 'Scripting' started by mehalon, Feb 17, 2018.

  1. mehalon

    mehalon

    Joined:
    Jun 13, 2017
    Posts:
    9
    Hi all,

    I am trying to create a simple UI with a menu bar on top and the main content (scrollview) below. Both is attached to a canvas with a VerticalLayoutGroup.
    When clicking on on a button in the menu bar, I am displaying a dropdown menu with additional buttons, but so far this one was always displayed *behind* the main content, because the menubar (and thus everything belonging to it) was in the canvas hierarchy behind the main content.
    However I cannot change this because it would change the order in the VerticalLayoutGroup and the menu bar would be displayed on the bottom.
    After lots of research and different tries (changing the z value of the dropdown menu etc.), it seemed like I found the solution: adding a canvas component to the dropdown menu, overwriting the order and giving it another sorting layer. So now the dropdown menu is indeed displayed in front, however when trying to click one of the buttons, I instead click through them and actually end up clicking on the buttons of the main content view in the background.

    Here a screenshot to illustrate what I mean:

    screenshot.JPG

    Instead of clicking on "Map" I end up clicking on the big button in the background.

    Any ideas what I could do?



    PS: I just realized it's not really a Scripting question but rather a UI/2D one, sorry for the wrong sub-forum..
     
  2. tranos

    tranos

    Joined:
    Feb 19, 2014
    Posts:
    180
    I would create one panel. Inside that I would put the menu to display on top and another panel where it would be the main content with the VerticalLayoutGroup.
     
  3. mehalon

    mehalon

    Joined:
    Jun 13, 2017
    Posts:
    9
    Thanks for your answer, but I'm not entirely sure what you mean.
    Currently the scene looks like this:
    I have the drop down menu as a panel below the MenuButton (which is part of the MenuBarPanel). MenuBarPanel and ContentScrollView are part of the VerticalLayoutGroup of the mother canvas "meinCanvas".
    screenshot.JPG


    What exactly would you suggest to change in this setup?
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I think they were suggesting that you keep the vertical layout group on the content of your scroll view, rather than on your canvas.
     
  5. mehalon

    mehalon

    Joined:
    Jun 13, 2017
    Posts:
    9
    That worked, thanks guys!
     
    tranos likes this.
  6. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712