- Home /
Why does RectTransform.position ignore the scaleFactor of the canvas?
Hello everyone,
i set up a canvas with a scaleFactor of 1.5. I noticed that when i want to change a position of a rectTransform to a pixel i can still use the pixel coordinates like this:
rect.position = new Vector3(Screen.width * 0.5f, 0f, 0f);
However the position of the image isn't actually Screen.width * 0.5f in the inspector. It automatically devides the position by the scaleFactor when it is set it looks like. This is realy confusing to me. Especially because the rect.sizeDelta isn't automatically calculated. If i want to set the scale to a width in pixel i need to manually devide the scaleFactor like this:
rect.sizeDelta = new Vector3(Screen.width * 0.5f / scaler.scaleFactor, 10f);
Is there any reason for this or is it just Unity's calculations that are confusing?
Your answer
![](https://koobas.hobune.stream/wayback/20220612170641im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to instantiate a prefab between Canvas and a Button? 0 Answers
GUI Button On Click Event 0 Answers
Distribute terrain in zones 3 Answers