Positioning items in a container

Hello guys again) There is such a problem when you start to change the viewing area (when it becomes too large or small), the positioning of the golden background on the button moves out, although everything is set as a percentage. It is possible to somehow fix the position of the element inside the container or as -
is there another way to fix this problem? I will be especially grateful if someone tells me how to position the element inside the container in the center. pivot in babylon, as I understand it, is only for meshes. What about container positioning? Do they have an anchor point? Thanks for any help
https://playground.babylonjs.com/#V4KWNU#1

Hi @MartynovOleg

I’m not sure to understand. You want to lock the background to the top left of the button container?

Suppose I centered the golden background relative to the background (pictures), all this by adjusting the values ​​of top and left in percent.
In a certain size of the window in which I configured, everything is ok. But when you resize the window, the positioning of the button’s child (golden background) begins to shift,
that is, it is not centered already. Is there any way to avoid this? And is it possible to somehow do without adjusting the position of the child element in the center “by eye”? If you do not understand, I can rephrase, or ask any additional questions.
And yet, all this is translated through Google translator, so please excuse me)

Maybe you can tweak using pixel values instead of %:

https://playground.babylonjs.com/#V4KWNU#2

So it was originally, but I don’t know how correctly it will be displayed on different resolutions and mobile devices, the goal is to avoid pixelation (poor image quality) and fix the locations of gui elements, because now elements at different resolutions are displayed in different places)) on friend etc.
Or use percentages to arrange elements on the "main screen", and use pixels to arrange elements inside containers. Although, in theory, AdvancedDynamicTexture (what I mean by the main screen) where all the controls are located is the same container
I took the idea of ​​switching from pixels to percent from here:

But still, thanks) If I do not find another option, I will use this one)

1 Like