Search Issue Tracker
Fixed in 5.3.0
Votes
1
Found in
Issue ID
736161
Regression
Yes
RectTranfrom values of prefab with Canvas are lost after instantiation
How to reproduce:
1. Open the attached project
2. Open and play test scene (it has Test.cs script on Canvas GO which load and instantiate Button prefab with Top-Stretch anchors and then makes it child of Canvas)
3. Notice that button is not just on top, but stretched
4. Or compare coordinates before and after instantiation, it has changed
If Button prefab is dragged to the canvas, it keeps its RectTransform values
Not reproducible: 5.2.0b4
Comments (3)
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
- URPPreprocessBuild.OnPostProcessBuild is never executed when building the Player
- [Linux] Using CTRL+Shift+A shortcut for Add Component throws GUI Rendering Errors
- Crash on MonoBehaviour::Transfer<YAMLRead> when upgrading the Magic Leap XR Plugin
- Image is distorted when VisualElement is scaled and Scale Mode set to scale-and-crop
- Euler angles return different values during Animation Event when using Playables API and the time is 0
B16B0SS
Mar 24, 2022 19:32
The suggestion from KARL_JONES does not work in 2022.0.9b
karl_jones
Nov 05, 2015 17:51
Hi. The behavior changed in 5.2 as we fixed a bug causing canvases to not update when instantiated. We will add a delay in so the canvas does not update the rect transform on instantiate, this will maintain the previous behavior.
karl_jones
Nov 05, 2015 17:00
Hey. So this is not actually a bug. What is happening is the GameObject is instantiated at root level and so the Canvas component sets all the values for the screen, note if you change the canvas to a world canvas the values remain untouched. So a simple way to work around this is to disable the canvas in the prefab and then enable it once it has been parented.