0
\$\begingroup\$

I placed all elements in the places I want to show in the Game mode, nevertheless, when I go to Game Mode they are shown in the wrong place as it was shown in the pictures (they go to the center). I tried different modes of render mode but no one seems to work in this case. I want the elements to be fixed in the window no matter monitor size.

Scene Editor

Game Mode

\$\endgroup\$
  • 1
    \$\begingroup\$ Make sure your elements are properly anchored. Also mind the scaling mode. \$\endgroup\$ – Sidar Apr 14 at 8:41
1
\$\begingroup\$

It looks like you didn't configure your anchors correctly.

Here, I'd recommend creating a parent object for each cluster of controls on your screen, like the drop-down and grid of numeric widgets in your top-left corner. This will let you control the layout of objects within that cluster, independent of the location and size of that cluster on the screen.

Next, you'll want to set that cluster's anchors to the top-left of your canvas, by clicking on the anchor presets in the top-left of its RectTransform.

enter image description here

Also, place your pivot in the top-left corner of the shape, by setting Pivot.x = 0 and Pivot.y = 1.

Now, your PosX and PosY variables control the margin between this cluster of controls and the left / top sides of the display, and the width & height control the size of the parent (you can set up the controls inside to layout/scale within the bounds of the parent, if you like)

Try changing the shape of the game window inside the editor, to watch how the object repositions to stay tucked into the corner. Then, apply the same principles for items you want docked against top/right/bottom edges of the screen. By setting the anchor min/maxes to a fractional value, you can make the object stay glued to a point some percentage of the way along the screen.

\$\endgroup\$

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.