Search Issue Tracker

By Design

Votes

0

Found in

5.3.1f1

Issue ID

764690

Regression

No

Can't get accurate transform.position of a Grid-Set RectTransform in Awake/Start

UI

-

How to reproduce:
- Open MainScene from the attached project
- Turn on Play Mode
- Camera should locate to an offset Z position from the Red Frame. However, it actually sets to somewhere near the bottom left corner of the World Canvas
- Hitting Next should locate the camera to the correct position of each of the Color Frames
- Leave Play Mode
- Turn off the Grid Component (WorldCanvas -> FrameHolder -> Grid Layout Group)
- Turn on Play Mode
- The Camera should relocate to view the Red Frame, as intended
- It should also locate as intended if SetNewPosition method is in an Update

By Design: The grid system lays out the items during a layout call. Until that time the data is not known. Notice how the Frames under the grid component say "Some values driven by GridLayoutGroup" that means that they are only stored as zero. To correct this you'd need to have it in start and use a coroutine to wait till end of frame

IEnumerator Start(){
yield return new WaitForEndOfFrame();
SetNewPosition();}

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.