Author Topic: Moving object with Center on child  (Read 8894 times)

Isamson

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 52
    • View Profile
Moving object with Center on child
« on: April 30, 2014, 02:52:32 PM »
Hi,
I'm attempting to move the parent of a uitable while it's performing a Center on child. For some reason the tween within the Center on child stops if the objects parent is moved or tweened.

Is this a normal behavior? Is there a workaround for this?

Edit 1: Here is what I noticed:
The Spring Panel's Target XYZ usually matches the x,y,z position of the UIPanel. But if I move the parent of the panel doing the Center on child, the UIPanels X position (the one being tween by the Center on child) changes to a different value. It basically un-syncs with the Spring Panel if it's moved and the Center on child simply stop centering the panel.
« Last Edit: April 30, 2014, 03:10:27 PM by Isamson »
Unity 4.5.3f
NGUI 3.7.0

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Moving object with Center on child
« Reply #1 on: April 30, 2014, 05:55:10 PM »
UICenterOnChild goes to a specific position. If you move the children after it's initiated, it will effectively be moving to the "old" position.

Isamson

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 52
    • View Profile
Re: Moving object with Center on child
« Reply #2 on: May 01, 2014, 07:47:20 AM »
Is there anyway around this? I was under the impression that the Center on child was using the Local Position, so I thought it wouldn't be influenced by a tween on the parent.
Unity 4.5.3f
NGUI 3.7.0

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Moving object with Center on child
« Reply #3 on: May 02, 2014, 07:51:30 AM »
UICenterOnChild just uses SpringPanel, which uses local space coordinates. It adjusts the panel's position by one value and the clip offset by the opposite, thus resulting in the content moving into place. Can you draw the hierarchy of where everything is?

Isamson

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 52
    • View Profile
Re: Moving object with Center on child
« Reply #4 on: May 02, 2014, 07:59:22 AM »
Sure thing,

UIRoot
    - camera
        -Panel (main)
            -anchor
                - offset (empty GO)
                    - tween (this is the object moving)
                        - offset for Panel
                             - Panel (clipped) containing the Spring Panel

So I'm tweening the tween at the same time I'm calling the center on child.         
     
Unity 4.5.3f
NGUI 3.7.0

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Moving object with Center on child
« Reply #5 on: May 02, 2014, 09:33:02 AM »
Aside from it being overly complicated, and the fact that there shouldn't be the "anchor" there, I see nothing wrong with the hierarchy, so I honestly am not sure what to suggest.

Isamson

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 52
    • View Profile
Re: Moving object with Center on child
« Reply #6 on: May 02, 2014, 09:36:14 AM »
I'll find a work around. Probably do the tween first and after that apply the spring panel.
Unity 4.5.3f
NGUI 3.7.0