Search Issue Tracker
By Design
Votes
0
Found in
2018.3.0a11
2018.3.0b9
2019.1.0a1
Issue ID
1098050
Regression
Yes
Rect of instantiated rect transform is only resized on second frame
Steps to reproduce:
1. Open attached project
2. Open scene SampleScene
3. Run it
4. In console, notice that there's one RectTransform rect value different from others. This happens because rect transform is only resized in the next frame and not the same one it was instantiated on.
Reproduced with: 2018.3.0a11, 2018.3.0b9, 2019.1.0a1, 2019.1.0a8
Not reproducible: 2018.2.15f1, 2018.3.0a10
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Tile Palette grid is moved after entering Play Mode
- Tile Palette Edit mode turns off in Play Mode
- The Editor crashes when Generating Font Atlas in the Font Asset Creator with “9999999999” padding and 256x256 Atlas Resolution
- [iOS] An “ArgumentNullException” error is thrown when GetIntroductoryPriceDictionary() method is called
- Font Import Settings documentation page is missing when the documentation button is pressed in the Inspector window
Resolution Note (2019.1.X):
This is because CanvasScaler is used on this object, which has its own 'Awake' to perform.
The order of Awakes is not guaranteed, and should be considered random. Unfortunately it can have the appearance of being consistent, and can be the same for a given object each time it's run, but is sensitive to change in the underlying Unity codebase, or in the Unity project.
When the CanvasScaler Awakes, it performs calculations based on screen size (or however it's set up), which causes the Canvas to be modified, which in turn causes child rect transforms to be modified.
The best place to 'capture' the initial rect transform is in the Start() method of the component, when all Awakes are guaranteed to have run.