Author Topic: Button Scale Affects Collider  (Read 8340 times)

vexir

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 47
    • View Profile
Button Scale Affects Collider
« on: October 01, 2014, 05:28:06 PM »
UIButtonScale seems to affect the collider's scale as well. This results in issues where the scaling causes the collider to no longer be under the finger and the touch gets thrown out. Is this something that you're aware of?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Button Scale Affects Collider
« Reply #1 on: October 01, 2014, 05:30:14 PM »
Can't say that I am. What's your setup?

vexir

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 47
    • View Profile
Re: Button Scale Affects Collider
« Reply #2 on: October 01, 2014, 06:58:39 PM »
NGUI 3.6.3. Might be a little risky to at this stage in the project; though I would if it fixed this. UI Root set to Fixed Size On Mobiles. Standard UIButtons with UIButtonScale script on them. Testers keep trying to press buttons on the edge of collision at which point it drops out and doesn't register as a press.

vexir

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 47
    • View Profile
Re: Button Scale Affects Collider
« Reply #3 on: October 01, 2014, 07:01:19 PM »
Another note - you can tell it happens because although the button stays scaled, the color reverts back to a non-pressed color.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Button Scale Affects Collider
« Reply #4 on: October 02, 2014, 09:59:00 PM »
Yeah that's 11 versions behind, can't say much about that.

huhudage

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Button Scale Affects Collider
« Reply #5 on: December 22, 2014, 02:06:38 AM »
This problem seems still exists in 3.7.6, how to resolve this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Button Scale Affects Collider
« Reply #6 on: December 22, 2014, 10:22:51 AM »
So what's the issue exactly? How do I reproduce it?

huhudage

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Button Scale Affects Collider
« Reply #7 on: December 22, 2014, 09:21:48 PM »
So what's the issue exactly? How do I reproduce it?

If attach a UIButtonScale component to a button, with (1, 1, 1) as 'Hover' property and (0.8, 0.8, 0.8 ) as 'Pressed' property, when I press at edge of the button, the OnPress callback will not be triggered because the collider is no longer under my finger.
« Last Edit: December 22, 2014, 09:29:40 PM by huhudage »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Button Scale Affects Collider
« Reply #8 on: December 23, 2014, 12:02:57 PM »
Oh, well yeah. Collider won't be underneath that button anymore after the scaling operation.

If you want the collider to stay the same size, then you need to separate it from the viewable component like so:

UIWidget (collider, button component)
- Sprite (visible sprite that will scale)