Author Topic: There is a problem with the update of worldToLocal of UIPanel.(Var 3.6.3)  (Read 3655 times)

kakkou

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
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 .


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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
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.

kakkou

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Currently UIPanel's OnEnable function is this:
  1.         protected override void OnEnable ()
  2.         {
  3.                 mRebuild = true;
  4.                 mAlphaFrameID = -1;
  5.                 mMatrixFrame = -1;
  6.                 base.OnEnable();
  7.         }
If the mMatrixFrame is reset to -1 at the end, would it fix your issue?
  1.         protected override void OnEnable ()
  2.         {
  3.                 mRebuild = true;
  4.                 mAlphaFrameID = -1;
  5.                 base.OnEnable();
  6.                 mMatrixFrame = -1;
  7.         }

kakkou

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
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.

kakkou

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
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.

Please check please.

NGUIInventryTest.unitypackage

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Thanks, I am looking into this.