Author Topic: Component ordering causes different behavior with Buttons  (Read 2103 times)

Grimicus

  • Guest
Component ordering causes different behavior with Buttons
« on: October 02, 2012, 04:45:37 PM »
I've been trying to build a UI that works similar to the example #4 (Controller Input) in the NGUI package.   In my own code though I was having a strange problem with the onhover coloring from my UIButton component.  It was not working correctly when I transitioned between my different panels using UIButtonPlayAnimation components.  In the example, it was working fine.

I was able to reproduce this in the example by recreating the UIButtonPlayAnimations components on "Panel - Main/Window/Button - Options" and "Panel - Options/Window/Button" that drive the transition between panels.  I made them so that they were after the UIButtonKeys component and deleted the original ones.   When this happens, the tween color stuff that is managed by UIButtonColor (or UIButton) never triggers and so you are left with no onhover highlights after the transition.  I was able to get it working again by recreating the UIButtonKeys component and deleting the original which put it after the UIButtonPlayAnimations again.

I just thought I'd let you know since ideally component order shouldn't be necessary, especially since you can't actively reorder them as far as I know.  For now, I'll just make sure I keep my ordering correct so I can get my UI working.

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Component ordering causes different behavior with Buttons
« Reply #1 on: October 02, 2012, 04:57:24 PM »
You need to have a UIButtonKeys component give focus to something else when clicked (UIButtonKeys.selectOnClick). Without it, the focus won't be transferred.

Grimicus

  • Guest
Re: Component ordering causes different behavior with Buttons
« Reply #2 on: October 02, 2012, 06:10:34 PM »
I did have it setup that way which is why I tested it in the example to try and figure out what was wrong since it worked there.  Once I rearranged where the UIButtonPlayAnimation and UIButtonKeys were in relation to each other in the GameObject the problem appeared in the example as well.  Originally I thought it was a strange difference between UIButton and UIButtonColor but it really has to do with all of those components interacting together to produce it.