Strange position issue

Hi there.

I try to change a canvas position by c# command:

public void SwitchWindows()
    {

        ContainerWindow.GetComponent<RectTransform>().position = new Vector3(100, -20, 0);

        print("Old position: " + ContainerWindow.GetComponent<RectTransform>().position);
        
        ContainerWindow.GetComponent<RectTransform>().position = new Vector3(880, -20, 0);

        print("New position: " + ContainerWindow.GetComponent<RectTransform>().position);
        
    }

The final position is kinda odd; there is no miss-scaled parent, no layout component, the position of the window is not driven by anything else! For checking a correct transformation, I make first a step in between (100, -20, 0), print position, then the final one (880, -20, 0), and print position again…

I keep getting this result (look at the prints and the position):

@Ambrose998800 The problem is you are expecting RectTransform to behave like transform. In RectTransform the PosX and PosY are relative to the anchor position and scaled according to the parent Canvas.

Change your anchor from bottom-left to middle-center and the values will behave more like you expect.