- Home /
Moving a UI object from one Canvas to another doesn't apply scaling
I have two canvases with different canvas scaler settings. I also have a panel. If the panel starts on either Canvas, it is scaled correctly. BUT: If the panel starts on one canvas, and I move it to the other one with a script (changing the parent to the other canvas), it is not scaled to match the new Canvas' Canvas Scaler settings.
How can I force the UI object to rescale to match the new Canvas' Canvas Scaler settings?
Answer by Vega4Life · Dec 27, 2018 at 01:49 PM
By default, when you set the parent of a gameObject, it retains its current world space rotation, scale, and position. You can override this when setting the new parent.
panel.transform.SetParent(canvas.transform, false); //Pseudo
By setting worldPositionStays to false, it will now take on its parent scale.
Your answer
![](https://koobas.hobune.stream/wayback/20220612184638im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Image on UI doesn't stretch when objects it's on is stretched. 0 Answers
UI scaling too big after build 0 Answers
Unity Dual Monitor Size Bug? 1 Answer
Strange Canvas behaviour at Screen Space - Camera mode? 0 Answers
Using Hinge Joint 2D with scaled UGUI 0 Answers