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
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();}
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- NullReferenceException is thrown when overriding the UxmlObjectReferences in template instances
- Shaders created with Shader Graph generate a large amount of shader variants and cause slow build times when using a baked lightmap in BIRP
- Shader Graph Matrix property produces random output values when SRP Batcher is enabled
- "Untracked" memory is logged by the Profiler when small allocations for delegates and big allocations for new array creations happen simultaneously
- Rotation value change on the X-axis gets stuck when using transform.rotation.eulerAngles
Add comment