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

Unity UI Register Clicks Outside Of Scrollview Mask

Discussion in 'UGUI & TextMesh Pro' started by ConorArup, Aug 28, 2018.

  1. ConorArup

    ConorArup

    Joined:
    Feb 15, 2018
    Posts:
    17
    I have a drop-down menu that is displayed outside of a ScrollView's Mask component (using an altered shader that ignores the Mask), however, the input is still being blocked outside of the Mask.

    How can I enable certain Toggles to be clickable even outside of a particular Mask?
     
  2. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,078
    why don't you simply remove the mask from the viewport?
     
  3. ConorArup

    ConorArup

    Joined:
    Feb 15, 2018
    Posts:
    17
    I would have done that already if I didn't need it.

    I'm using a vertical ScrollView to contain multiple elements in a sidebar so need the mask to obviously remove elements further down the list from view.

    These elements, however, are clickable with one opening a drop-down menu outside of the mask which I need to be responsive.
     
  4. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,078
    hmm, okay...
    I have an Idea how to solve it, but I actually don't know the exact setup.
    I got the idea I have from a problem I recently had where I wanted to have an inverted mask (so that I have a whole in a sprite which can move). I found the solution here: https://answers.unity.com/questions/1066291/invertreverse-ui-mask.html

    So, I guess you can do it similar: remove the mask component and use your own mask shader instead. Then all masked objects beneath probably need a special shader as well. The non-masked ones use the default shader, so that they are rendered anyways.
    However, this can be tricky if you have a lot of stuff inside (including text). Another problem: you could click the masked objects.

    Maybe another approach would be even better, where you put the drop down into another parent outside of the scroll view...
     
  5. ConorArup

    ConorArup

    Joined:
    Feb 15, 2018
    Posts:
    17
    The first idea wouldn't work because I don't want objects below the mask outside of the scrollview's view to be selectable as that should work as default. It's just the objects which are displayed on button clicks. I guess they could be put in another parent but then I wouldn't be able to anchor them to the location of the original element.
     
  6. Hosnkobf

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    1,078
    true. you would need a custom script to kind of "anchor" it and set (or even update) the position properly.
    That is not an easy task, but it is doable (and I thought about doing it in the past a few times already... but didn't do yet).