Author Topic: Don't consume click (or, re-send click event to entire UI)  (Read 1540 times)

frezned

  • Guest
Don't consume click (or, re-send click event to entire UI)
« on: March 12, 2013, 01:35:32 AM »
As part of a menu system, I want to put a collider over certain parts of the UI after a certain event that will respond to a click, but also count as a click for whatever happens to be below it.

Is there some way that I can disable all of those colliders in the colliders' OnClick function, and from there send another click as though the user had pressed again?

I know I can SendMessage("OnClick") to a specific element, but I want it to just go to wherever the user clicked.

I suppose the alternative to all this is to do a raycast from the UICamera manually, and then send OnClick to whatever collider is encountered there... is there a quick way to do this? GetObjectUnderMouse or something?

Cheers,
Tom

Edit: I've achieved this by making UICamera.Raycast public and calling it like this:
  1.         RaycastHit hit = new RaycastHit();
  2.         GameObject go = UICamera.Raycast(Input.mousePosition, ref hit) ? hit.collider.gameObject : UICamera.fallThrough;
« Last Edit: March 12, 2013, 02:15:13 AM by frezned »