Author Topic: Wrong position and scale for duplicated object.  (Read 2957 times)

LightStorm

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 17
    • View Profile
Wrong position and scale for duplicated object.
« on: May 27, 2014, 04:02:59 AM »
Hi, Aren.
There is a annoying behavior in NGUI with duplicating objects in Editor. Duplicated object has wrong position and scale which are not the same as position and scale of original object.
For example:
original object has - position{333, 384, 0}; scale{1, 1, 1}
duplicated object has - position{333.0002, 384, 0}; scale{0.999936, 0.999936, 0.999936}

It can be easily fixed by pressing Alt-Shift-P (Make Pixel Perfect) but why NGUI can't handle this?

Thanks.

jingato

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Wrong position and scale for duplicated object.
« Reply #1 on: May 27, 2014, 03:36:49 PM »
I believe this is actually a Unity bug, not NGUI.

LightStorm

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 17
    • View Profile
Re: Wrong position and scale for duplicated object.
« Reply #2 on: May 28, 2014, 01:15:51 AM »
I don't think so. This can be easily verified..
Just create empty GameObject (not NGUI) and set it scale to something like {0.002604167, 0.002604167, 0.002604167} (normalized numbers like in NGUI Root).
Then add child GameObject inside it and adjust it position. Now if you press Ctrl-D on it (duplicate) it will be cloned and new GameObject will have exactly same scale and position.
So it's NGUI bug.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Wrong position and scale for duplicated object.
« Reply #3 on: May 28, 2014, 06:09:33 AM »
Unity bug, as jingato said. Happens when you duplicate an object that was parented to something that was scaled.

Unity's scale calculation has long been bugged due to how it chooses to combine the final scale. Note how the transform has "localScale", but no "scale"? Instead there is "lossyScale".

CTRL+D is a Unity shortcut, not NGUI.

P.S. Following your instructions exhibits the same exact issue. Did you even try it yourself? Create a game object, give it a small scale, add a child to it (ALT+SHIFT+N will do), then duplicate that child via CTRL+D.

LightStorm

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 17
    • View Profile
Re: Wrong position and scale for duplicated object.
« Reply #4 on: May 28, 2014, 07:33:16 AM »
Hmm.. strange things..
Of course I have tried it myself and it works on specified values (from my previous post).
I just checked it again with different scales and saw that it's a Unity bug. My apologies.

May be there is a solution to handle "Duplicate" command and do "Pixel Perfect" right after it?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Wrong position and scale for duplicated object.
« Reply #5 on: May 28, 2014, 07:50:48 AM »
If there is, I am unfortunately not aware of it.