Author Topic: UIWidget on UIImageButton - Collider Not Scaling  (Read 3113 times)

merlin981

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
UIWidget on UIImageButton - Collider Not Scaling
« on: January 08, 2014, 12:40:02 PM »
I'm using NGUI v3.0.8 f3.

I have several UIImageButtons in my scene with box colliders. I added a UIWidget to each, set Anchors to "Unified", and adjusted the targets accordingly so the buttons will move/scale as resolution changes. This part works just fine.

In the UIWidget component is a property "Box Collider auto-adjust to match". When I check this, it changes my box collider's size to 100,100. It keeps the size at 100,100 regardless of the screen resolution. All my buttons are the same size - in the default resolution they are 168, 168 in size. Their sprites list the size as 168, 168.

When the scene is run, the box collider is not covering the entire button, only the middle portion of the button.

In the attached screenshots, you can see in image #2 that the box collider is only covering the middle portion of the button.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIWidget on UIImageButton - Collider Not Scaling
« Reply #1 on: January 08, 2014, 12:46:44 PM »
"Adjust box collider" option only adjust the collider present on that widget. In the 168x168 picture you don't have a box collider present, so there is nothing to auto-adjust.

I'm also a bit unclear on your setup. UIImageButton is a script, not a widget. Script that goes on a sprite. In this case there is no reason to add extra UIWidgets. Attach the box collider to your sprite instead.