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

UI Multiple Interactions at once

Discussion in 'UGUI & TextMesh Pro' started by MRKane, Aug 26, 2015.

  1. MRKane

    MRKane

    Joined:
    Oct 4, 2012
    Posts:
    54
    Hello all,

    I'm stuck with a rather unique problem. I'm trying to use a slider with buttons along it (for events in a timeline), thing is the buttons block interaction with the slider and I'd like to receive input from both at the same time as they're used as an "intuitive" approach (thank the design team) to displaying information.

    I've tried using a canvas group setting interactive on, and blocks raycasts off - however if anything is set to not blocking raycasts it cannot be interacted with. I'm using 5.1.3 and wondered if there was a component or method someone knew about that could help me with this!

    Thank you so much!
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    I think the simple answer is that you can't. UI interactions are evaluated by raycasts, so if one interactable UI object is on top of another, then you only interact with the object on top.

    You could write your own event system (copying Unity's one from source) and modify it to interact with all depths maybe (possibly using your own version of a graphics raycaster as well) but it'd be a lot of work.

    What I'd probably recommend, is making the buttons non-interactable in their own canvas group, then have a script on the slider that also checks the position on the slider the player has touched and if it's in the region of the button, then also activate the buttons click event using "ExecuteEvents.Execute()"

    Hope that helps.
     
    MRKane and Senshi like this.
  3. MRKane

    MRKane

    Joined:
    Oct 4, 2012
    Posts:
    54
    Yes that does help - a good definitive answer :D
     
    SimonDarksideJ likes this.