Author Topic: Multiple widgets on one gameobject possible bug  (Read 2923 times)

dkozlovtsev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Multiple widgets on one gameobject possible bug
« on: October 15, 2013, 01:56:28 AM »
Hello, I'm trying to do a button that is contained inside one gameobject.
Among other problems i've encountered an issue when trying to change gameobject position only one of the widgets actually moves(see attached images)
I think its a bug :/

Loosely related question - is it possible to set collider to automagically scale to cover whole widget?


« Last Edit: October 15, 2013, 03:55:55 AM by dkozlovtsev »

simon129

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 20
    • View Profile
Re: Multiple widgets on one gameobject possible bug
« Reply #1 on: October 15, 2013, 02:06:47 AM »
It's under menu [NGUI] => [Attach] => [Collider].

Or you can use the hotkey by pressing  [Alt]+[Shift]+[C]

dkozlovtsev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Re: Multiple widgets on one gameobject possible bug
« Reply #2 on: October 15, 2013, 02:16:11 AM »
It's under menu [NGUI] => [Attach] => [Collider].

Or you can use the hotkey by pressing  [Alt]+[Shift]+[C]

I know about this feature, but i need to do it automaticaly, meaning when widget size changes collider automatically changes its size to cover it.

About the bug:
I found that during update Widget.HasTransformChanged() is being called
inside there is the following code
  1.                 if (cachedTransform.hasChanged)
  2.                 {
  3.                     mTrans.hasChanged = false;
  4.                     return true;
  5.                 }
  6.  

it won't work in case of multiple widget on one gameobject, because in that case two widget share the same cached transform(at least it seems that way), and what widget is the first to render sets cachedTransform.hasChanged to false. Preventing update of all the other widgets.
« Last Edit: October 15, 2013, 03:03:57 AM by dkozlovtsev »

dkozlovtsev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Re: Multiple widgets on one gameobject possible bug
« Reply #3 on: October 19, 2013, 01:15:53 PM »
hmmm, bump

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Multiple widgets on one gameobject possible bug
« Reply #4 on: October 19, 2013, 08:36:23 PM »
While you can put more than one widget on the same game object, doing so may give unpredictable results since both share the same transform value. So... don't do it. The functionality is there for advanced users that know that two widgets will have nearly identical settings -- but even so it's questionable for the time being and I may end up removing support for it in the future.

To update the collider's dimensions automatically, it's best to do it via code based on whatever is causing it to resize to begin with. So if you're resizing a widget in some function, also update its collider size right then and there.