Author Topic: Box2DColliders size on 2D_UI  (Read 1525 times)

Creadth

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Box2DColliders size on 2D_UI
« on: July 06, 2014, 11:36:37 AM »
Hi, I'm working with NGUI for few days and have some strange problem. I have an asset called Contextual, which is used for creating contextual menues for objects in game. When u click an object and menu should appear, it creates a UIWidget using NGUITools.AddWidget function for each menu item. As I've understood, this function adds a new widget to the UIRoot and creates a collider for that widget, depending of what UI type I've selected (BoxCollider for 3D_UI and BoxCollider2D_UI). After that collider is being autoresized to the size of a widget. Everything is ok while in editor or event web player. But when building for windows it seems that collider is not being resized correctly (I've manually scaled it 10x times and it has started receiving NGUI events). Since it is very hard to debug on standalone build + being new to NGUI I'm stuck with this bug for a few hours. Any help would be appreciated.
P.S. Sorry for my English, I'm russian and there could be a lot of mistakes :(
Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Box2DColliders size on 2D_UI
« Reply #1 on: July 07, 2014, 01:58:53 AM »
AddWidget merely creates a widget under the specified parent. It won't add a collider for you. NGUITools.AddWidgetCollider is what will add a collider.

Creadth

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Box2DColliders size on 2D_UI
« Reply #2 on: July 07, 2014, 04:44:15 AM »
Yup, I found that it calls AddWidgetCollider too. It seems that depending on resoultion collider is not where it should be and with wrong size. It also depends of minimum/maximum height parameters set for pixel perfect option. I've fixed it by switching from 2D_UI to 3D_UI, but I'm not very satisfied with two types of colliders for GUI and game objects.