I ran into a issue today that is driving me insane.
I swear there is no reason why it should be doing this.
ConsoleWindow is a RectTransform
I’m telling it to move -155.3f
but instead it moves 265 positive.
If I disable this code then it won’t move at all.
So i know there is nothing else effecting it.
I even wrote up a test to have it move a minute after game load and it still does it.
Anchors are not being changed.
My editor and during game play. the anchors are
0 0.5
0 0.5
Pivot .05 .05
Also after game load if I move the RectTransform to -155.3f its exaxtly where it should be.
So right there says its not a anchor issue or an parent effecting it.
How do I make the editor mimic what anchor position is doing?
I noticed the x position of anchor Position in script doesn’t match exactly to the editor value. It’s off by like 50.
The anchoredPosition is the relative position of your pivot to the anchors.
If your pivot is [0.5, 0.5] (center), your anchors are [0, 1], [0, 1] (top left) and you want to position your transform’s top left corner absolutely, you would have to incorporate the transform’s half width and height into your position. A better way would be to set your pivot to [0, 1] (top left).
You also can toggle “Raw Mode” (the “R” Button in the RectTransform inspector) and change the pivot values to see how they would behave when setting them from script.
I hope I understood you question correctly and this helps.