Author Topic: Box colliders stop working after UIRoot resize  (Read 9731 times)

antondev

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 4
    • View Profile
Box colliders stop working after UIRoot resize
« on: January 25, 2015, 12:05:58 PM »
Hi everyone, stuck on this for a while and hoping to get some help:

I have a (standalone PC/Mac program) scene where I update the UI when the window is resized. The program launches at 1024x768 and any time you resize it to be wider than it's launch width (1024px for me), all the colliders in the UI stop responding--though I have confirmed they're in the correct place. This only happens with the compiled program, and not while running in the Unity Editor.

In my case, I have buttons on the left and right side of the UI screen, which are anchored to their respective edges. However, I need them to scale based on the height of the screen. What I do is, I set UIRoot to have width=1024, height=768, and for both I check "fit". Then, when the program is resized, I change UIRoot's manualWidth and manualHeight properties to the new screen ratio (I enforce a min and max ratio). I also call ResetAndUpdateAnchors on my top-level parent UI widgets, which causes them to actually update to UIRoot's new dimensions. When I do this, though, the buttons on the screen don't work anymore and the colliders, while in the proper locations, don't receive a click event.

So far I've tried using NGUITools.UpdateWidgetColliders() so far with no luck, along with disabling and re-enabling the collider after resizing. Am I missing something? What am I doing wrong?
« Last Edit: January 25, 2015, 12:15:03 PM by antondev »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Box colliders stop working after UIRoot resize
« Reply #1 on: January 25, 2015, 08:40:56 PM »
I see no reason for them to stop working, unless you have the static flag toggled on the UIPanel or the widgets don't have "adjust box collider" turned on.

I suggest enabling Debug flag on the UICamera to see what's under the mouse.

antondev

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Box colliders stop working after UIRoot resize
« Reply #2 on: January 26, 2015, 04:15:09 PM »
Thanks for responding. I checked and every UIPanel has the static flag off, and "adjust box collider" is enabled on all widgets that have one. Using debug mode on the camera outputs "Last Hit: UI Root" no matter what when I resize the window larger than the opening size. I also confirmed that the collider exists, and is in the location where I am clicking. Even with all other colliders turned off, it's not getting picked up. What would you recommend as a next step?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Box colliders stop working after UIRoot resize
« Reply #3 on: January 27, 2015, 04:24:37 AM »
I would suggest creating a very simple repro case for me to look at. You can send a download link via email to support at tasharen.com, or just attach it here -- just please don't include NGUI itself.

antondev

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Box colliders stop working after UIRoot resize
« Reply #4 on: January 27, 2015, 07:22:31 PM »
I emailed you the repro case and link earlier today. Please let me know if you didn't get it. Thanks so much for your help!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Box colliders stop working after UIRoot resize
« Reply #5 on: January 28, 2015, 02:20:31 AM »
I got it, and everything works as expected here, which begs the question... what version of NGUI do you have?

antondev

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Box colliders stop working after UIRoot resize
« Reply #6 on: January 29, 2015, 06:13:13 PM »
Thanks so much for looking into this!

A follow-up from the email conversation: it turns out that the problem was the version of Unity I was using to build. I was using Unity 4.6.1 (latest version at the time) and this version caused the bugs. When downgrading back to Unity 4.5.5 the problem went away. I also downloaded Unity 4.6.2f1, which just came out, and tried it out there, and the problem also exists.

Thanks again for your help, and I hope this all helps anyone experiencing this issue.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Box colliders stop working after UIRoot resize
« Reply #7 on: January 30, 2015, 03:17:56 PM »
Please submit a bug to Unity so they fix it. Regression issues like that are always important.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Box colliders stop working after UIRoot resize
« Reply #8 on: February 03, 2015, 10:46:01 AM »
I just gave this a shot in Unity 4.6.2 and again it seems to work as expected...

Made a simple test:
1. New scene.
2. Sprite, anchored to top-left in the top-left corner.
3. Collider on it.
4. Button script on it.
5. Hit Play, resized the window, works as expected.
6. Built stand-alone with a resizable window, ran it, resized the window, everything still works as expected -- button gets highlighted.