OnMouseOver() OnMouseDown() button raycast help

Hello I was wondering if there was a way to detect two object's colliders that are in front of one another.

I am trying to create a simple GUI system using two planes attached to bones (to save draw calls). The root bone is in a Group called GUI MESH.The bones work fine and my hideGUI script below works. What i'm trying to do is have the buttons float up off screen when your cursor is not hovering over the top left area (where the buttons will be). The hideGUI script does its job and uses:

function OnMouseExit(){

    hover = false;
}

function OnMouseOver(){

    hover = true;

}

and my quitScript uses

function OnMouseDown(){

    Application.Quit();
}

So my hierarchy goes:

  GUI MESH     (has a collider, attached hideGUI)
    --GUI_ROOT   (rootBone)   
      --restartButtonBone (have collider, attached restartScript)  
      --quitButtonBone    (have collider, attached quitScript)

Both scripts work individually but when the buttons float back onto screen their colliders get in the way so i can now click on the buttons but they are floating away (as if the hideGUI script no longer detects the mouse hovering over).

Any ways to have both of them function even though one collider my be infront of the other?

1 Answer

1

If you are using raycast to detect the buttons, then it wont work since the raycast will only detect the first one.