Support => NGUI 3 Support => Topic started by: kakkou on June 20, 2014, 12:35:04 AM
Title: There is a problem with the update of worldToLocal of UIPanel.(Var 3.6.3)
Post by: kakkou on June 20, 2014, 12:35:04 AM
UIPanel.worldToLocal will be updated by calling the UIPanel.UpdateTransformMatrix. However, since the frame count is recorded , then calling the method again in the same frame during the count will not be updated . Therefore , UIPanel.UpdateTransformMatrix is being called in advance , changes to the UIPanel.transform are not reflected in the UIPanel.worldToLocal.
The problem occurred under the following conditions .
1.Place the GameObject with UISprite children to GameObject that has a UIPanel. 2.I will deactivate the GameObject with UISprite. (To the value to True of UIRect.mStarted) 3.I want to activate the GameObject with UISprite. And I move the GameObject with UIPanel use PositionTweener. ( I do at the same time by a script) 4.SpriteMesh generated by UIPanel has shifted . (http://www56.tok2.com/home/kakkou/cgi-bin/imgboard/img-box/img20140620143201.png)
When GameObject with UISprite is activated, UIPanel.UpdateTransformMatrix() is called in UIRect.OnEnable(). transform.positon of UIPanel moved by PositionTweener is not reflected in UIPanel.worldToLocal. Therefore, the relative positions of the UIPanel and UIWidget are not displayed correctly.
Title: Re: There is a problem with the update of worldToLocal of UIPanel.(Var 3.6.3)
Post by: ArenMook on June 21, 2014, 02:29:12 PM
UpdateTransformMatrix() is called in LateUpdate(), and the frame counter is reset in the panel's OnInit (which is first called in Start(), and later on -- in OnEnable()). LateUpdate() will never be called before to Start() or OnEnable(), meaning the matrix will not be calculated yet. The matrix is updated only in LateUpdate, and only once per frame. I'm not sure I understand what issue you're running into. Activating a panel that has been started will invalidate its frame counters because OnInit() will be called again.
Title: Re: There is a problem with the update of worldToLocal of UIPanel.(Var 3.6.3)
Post by: kakkou on June 22, 2014, 09:57:07 PM
Thank you for reply .
UIPanel.UpdateTransformMatrix() called in UIPanel.LateUpdate() it, but it is certain In the case UIRect.mStarted is true, the problem is UIPanel.UpdateTransformMatrix() would have been called in UIRect.OnEnable(). UIPanel.UpdateTransformMatrix() is not updated at the timing of UIPanel.LateUpdate() of the frame count for that.
I put a screen shot the stack trace. (http://www56.tok2.com/home/kakkou/cgi-bin/imgboard/img-box/img20140623115349.png)
Title: Re: There is a problem with the update of worldToLocal of UIPanel.(Var 3.6.3)
Post by: ArenMook on June 22, 2014, 11:54:23 PM
Currently UIPanel's OnEnable function is this:
protectedoverridevoid OnEnable ()
{
mRebuild =true;
mAlphaFrameID =-1;
mMatrixFrame =-1;
base.OnEnable();
}
If the mMatrixFrame is reset to -1 at the end, would it fix your issue?
protectedoverridevoid OnEnable ()
{
mRebuild =true;
mAlphaFrameID =-1;
base.OnEnable();
mMatrixFrame =-1;
}
Title: Re: There is a problem with the update of worldToLocal of UIPanel.(Var 3.6.3)
Post by: kakkou on June 23, 2014, 01:12:38 AM
I have changed so after you upgrade to 3.6.5 , but did not improve .
I might have let the mistake to you for the lack of explanation. UIRect.OnEnable() called is not the UIPanel, is UISprite of its child hierarchy.
Title: Re: There is a problem with the update of worldToLocal of UIPanel.(Var 3.6.3)
Post by: kakkou on June 23, 2014, 02:15:52 AM
I was prepared the minimum package that contains the Script and Scene of occurrence of problem.(NGUI3.6.5 need)
Window will move to the center by pressing the button at the bottom center of the screen. When you press the button again , the window will move to the end of the screen. Second and subsequent problem occurs.