When moving UI object under other object scale is changing

Hello!

I have a problem: I need to make a bunch of buttons that is placed near each other. So in simple case I would just do something like: pos.x = base_offsetX + buttonWidth*btnIndex;
However… When I create the button in my script the scale of it is changed. So the formula above will not work anymore. Why on earth you do that ? Should I always take into account the scale ?

Thank you.

I had some issues with Scale when I changed the parent of my GUI buttons.
Try to reset the scale to 1,1,1 before adjust their position.

obj.GetComponent<RectTransform>().localScale = new Vector3(1, 1, 1);