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
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
- UI Toolkit's MinMaxSlider snaps unexpectedly in Runtime
- [2D] [URP] Objects are rendered twice when Foremost Sorting Layer is enabled
- Physics applied to Rigidbody is not fully disabled when setting the Rigidbody to Kinematic
- Scene view turns black when using a custom Mesh Renderer
- VFX Graph ZWrite has no effect when using URP PostProcessing DoF effect
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.