Author Topic: Colliders failing on panel rotation  (Read 1647 times)

acriter

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 2
    • View Profile
Colliders failing on panel rotation
« on: March 17, 2014, 11:24:20 AM »
Hello!

I'm in the process of making a menu screen which is meant to appear as though engraved on a table.

Everything works fine with a Y rotation of 0. But when I rotate the panel (UI Root), either manually through the editor or by using a TweenRotation, the buttons become unpressable, despite the fact that the buttons' colliders appear to have rotated properly with the buttons.

This happens even when I use a TweenRotation to rotate the object to its current position:
TweenRotation.Begin(this.gameObject, 0, this.gameObject.transform.rotation);

I have provided screenshots of the menu hierarchy and the objects in question.

Any ideas?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Colliders failing on panel rotation
« Reply #1 on: March 17, 2014, 06:58:48 PM »
UICamera must be set to "UI" mode. If it's set to "World" mode, then it's going to have events based on Z rather than depth, behaving quite differently. Also, why would you rotate the UIRoot? Camera is a child of the UIRoot, rotating it would have no visible effect.

acriter

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Colliders failing on panel rotation
« Reply #2 on: March 17, 2014, 07:58:36 PM »
Thank you for the reply :)

The UICamera component is actually set on the main camera, rather than on the UIRoot, so rotating should have an effect.

Would you recommend against this? There will be other NGUI menus appearing on the table, so I thought it made the most sense to pull the UICamera out to the main camera.

It is set to "World" mode, as you mentioned - I was seeing a lack of menu responsiveness in "UI" mode - but I assume now that it is just a depth issue?

Thanks again!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Colliders failing on panel rotation
« Reply #3 on: March 18, 2014, 09:48:38 PM »
UICamera is a script that sends out events -- it's the NGUI event system. If it's on the main camera then I assume you don't actually have a UI-specific camera then, and just have your UI rendered by your game? In most games the UI is drawn using a separate camera instead and the layout system is built with that in mind. When the UI is drawn using the game camera things behave differently (as it's generally also 3D), and events are based on the distance from the point of intersect under the mouse to the camera's position rather than by the depth of widgets.