Author Topic: UIPanel with scroll buttons  (Read 2590 times)

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
UIPanel with scroll buttons
« on: June 21, 2012, 12:54:09 AM »
Ok, I have a UIPanel but instead of scrolling it with click and drag, I have a left and right button either side.
I click a button and then I move the scroller in code. Simple eh?

Unfortunately I can't get a click to register with the right button because (as I have found out) that the collider is mixed with the hidden elements in the UIPanel.

In other words all the other elements are obscuring the button collision so clicking there does nothing. If I move the button up above the scroller it works, just doesn't work when in the same axis as the scroller.
Any tips on how to get around this?

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: UIPanel with scroll buttons
« Reply #1 on: June 21, 2012, 01:24:27 AM »
Ok, well I think I have almost cracked this now. I moved the buttons for the left and right arrows slightly higher in the Z axis, however after checking the collisions in the editor, I can see that it is still possible to click the invisible buttons, I think I have cracked this now as all I need to do is just disable the buttons you can't see. Not quite sure why UIPanel hides the graphics but not the collisions, but anyhow.

If there is a better way to disable the buttons, I would love to know. :)

dlewis

  • Guest
Re: UIPanel with scroll buttons
« Reply #2 on: June 21, 2012, 01:27:24 AM »
Have you tried doing the trick where you put dunny colliders on either/all side of the panel so it takes the mouse click and doesn't pass it on. It's used in one of the scrolling list examples (but I was never able to get it working myself).

After you do that then all you would need to do is make sure the colliders/object for your buttons you want always active are above the dummy colliders.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: UIPanel with scroll buttons
« Reply #3 on: June 21, 2012, 03:37:26 AM »
I presume when you say dummy colliders you mean the left and right collider that appears in the UIPanel example?
Hmm. I will have a look and see if that makes a difference. I have this feeling it might stop my arrow buttons working.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPanel with scroll buttons
« Reply #4 on: June 21, 2012, 05:12:24 AM »
Cover the sides with a dummy collider to intercept events, then put your buttons on top of that.