Author Topic: OnHover and child UI elements  (Read 1742 times)

kLy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
OnHover and child UI elements
« on: April 23, 2013, 05:22:02 AM »
I do a lot of tweening On Hover and I've repeatedly come across a problem:
If OnHover changes the UI in any way (eg. show a child button on the panel by moving or fading it in), there is no way to access the newly visible elements without moving hover focus off the parent button and thereby sending the parent the OnHover(false) event which would make the child buttons disappear again.

Now it seems like right now the only solution that stays within the bounds of how NGUI is meant to work is to create another larger collider *behind* the original and use that to do the "hiding" work instead of doing the hiding with the OnHover(false) event. The problems with this though:
1. I have a lot of these kinds of elements and this approach starts getting messy really quickly.
2. It is not foolproof. If the user manages to move the mouse very quickly, it is possible to pass over the larger "hide elements" collider altogether and the child elements then won't get hidden properly.

Ideally there should be an option somewhere to have the OnHover events ignore child objects that are in front of the main element. For example doing a collider.Raycast to do raycast checks instead of Physics.Raycast to see if the mouse is over the element, but at the same time ignore all other colliders that might be in the way.

What do you think?

Thanks :)