Rect transform position keeps changing value randomly

I’ve got a row of buttons I’m trying to position manually. I set their rect transform X position to 300 like so:

After I input it, the position changes to something close, but each rect transform is incorrectly positioned by some random floating point value. Here you can see that it’s changed itself to 299.2984. Sometimes it’ll be off by a value less than 0, sometimes it’ll be four or five whole units off, all of its own accord, and it will change every time I try to put a new value into this field.

I’ve tried shutting off all the other scripts I’ve got attached and changing the anchor point to different things, but nothing seems to stop this from happening. Does anybody have any insight on what this is or how to fix it?

Figured this out largely thanks to @Glurth’s comment. Although it seemed like several entire units was a bit much to be attributed to floating point error, it isn’t if your object is nested inside something that’s scaled. This was a result of the entire menu being scaled to an extremely tiny size (less than 0.01) in order to fit the camera. After fixing the scale, the rect transform’s position values behaved correctly. I’m still not sure what led to the menu getting scaled to begin with, but imagine it had something to do with my noodling with different canvas settings.

For anyone for whom @NickCaligo42’s solution doesn’t work: I encountered a similar effect when dealing with a ScrollView->Viewport->Content hierarchy, where the Content position value kept changing when selected or the game run.

The issue had to due with the Viewport anchors being set to stretch and fill the size of the ScrollView, and the Content height specified in game units. I was able to fix it by changing the Viewport anchors so that only the non-scrolling dimension is set to scale to the size of the Scroll View, with the scrolling dimension anchors set to an edge and the width/height specified in game units (probably the same size as your Scroll View).

(Additionally, it seems that the the content must be larger than the viewport).


Scroll View has a width and height of 100x200, and you want it to scroll vertically.
You have the Viewport anchors set to X-min/max: (0,1), Y min/max: (0,1), and Left/Right/Top/Bottom set to 0.
You have Content anchors set to X-min/max: (0,1), Y min/max: (1,1), with a height of 300. Pos Y keeps changing randomly.

To fix, change the Viewport anchors to X-min/max: (0,1), Y min/max: (1,1), and height to your Scroll View height (should be changed automatically).

Hope this helps!

I had a very similar issue in Unity 2019.4.2f1, so its still not totally fixed, but for me the solution was making sure that the Content’s height was equal or larger than the Scroll View’s height. Something about the Content’s height being larger causes it to bug out slightly.