A text object is where the inspector says, but not where I expected it, and not where Debug.Logerror says it is. What I read as my "strengthTextObj.transform.position.x"SeeScreenPrint is -213 in the inspector but transform.position.x is logged as 111. Why might these be different?


From the Unity Rect Transform documentation :

Pos (X, Y, Z) Position of the rectangle’s pivot point relative to the anchor

From your image we can see that the anchor is the center of the Canvas, so relatively to this anchor, your text position is correct (x = -200). What your are debugging is "strengthTextObj.transform.position.x". From the Transform documentation :

transform.position : The position of the transform in world space.

The origin of the world is at the bottom left corner of your canvas, so relatively to this point, your debugging position is correct (x = 111).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.