I’ve got a curious case of an UI element moving for a reason I can’t figure out.
The element doesn’t have any scripts attached to it and no other scripts are present in the scene that have any references to the element. Also, the only parent of the element are the root and 2D Screen objects.
Yet, the element still gets a visible offset in comparison to the way it appears in the editor, once the scene is launched. I logged its position to the console, but it’s returning the same value as the one that appears in the editor.
Can anyone please tell me if I’m missing something here or is this indeed an error? Thank you.
The left grey box ( the one that moves when the scene is launched) is the object that’s highlighted in the hierarchy. You can see from the 2nd picture I posted that the anchor values on it are (0,0,0,0).
Is that what you were asking, or ?
I’ve changed the anchor values on the Sentence Button 1 to (0.5, 0.5, 0.5, 0.5), but now instead of the position being offset, the size of the button changes.
I guess I just don’t quite understand how anchors affect element position/size then… think you could just briefly explain why the size changes?
I checked the documentation but I still don’t understand what the value causing the size change that I started experiencing now could be.
The values on Sentence Button 1 that I have in my scene now are equal to the ones in the scene you linked.
Also, in my scene, Sentence Button 1 and Sentence Button 2 are almost identical to each other and by looking at them in the inspector I can’t pin-point any value that would cause such a change. Yet, Sentence Button 1’s size changes and Sentence Button 2’s doesn’t. And even if I make them swap positions, the Sentence Button 1 is still affected by the size change and the Sentence Button 2 isn’t.
Their status, as far as parent/child entity relationships go, are the same and their anchor values are also equal, just like their pivots. Is there some other setting I’m missing here?
I’ve closed the project now and re-opened it and then the size change was visible in the editor. I just changed it and now everything’s working the way it’s supposed to.
I tried changing the value before closing the project but I was still getting the unexplained size change when launching the scene.
Not sure what happened here but thanks for the replies. I guess it was just some kind of internal error with the editor.