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

UI

-

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)

  1. B16B0SS

    Mar 24, 2022 19:32

    The suggestion from KARL_JONES does not work in 2022.0.9b

  2. 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.

  3. 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.

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.