What is the best way to create 3 objects relative to each other?

I need help with creating three game objects as shown in the attached image:

  • The first object needs to stick to the left side of the screen.
  • The second object needs to stick to the right side of the screen.
  • The third object needs to stretch and fill all the space between the first and second objects.

This setup should be compatible with all mobile resolutions.

Thanks in advance.

9665078--1376363--Screenshot 2024-02-26 at 14.40.35.png

Use anchoring and percentages to controll how it scales.
This is easy with the canvas scaler

1 Like

How to do this?

Google unity canvas scaler or how to make responsive UI
I am not going to do your work

Here are the official docs on how to make your UI handle various resolutions and aspect ratios cleanly:

Here are some notes on UI Anchoring, Scaling, CanvasScaler, etc:

Usually you need to choose a suitable ScaleMode and MatchMode in the Canvas Scaler and stick with it 100%. Generally if you change those settings midway through, you will often need to redo your UI entirely.

I also use this CanvasScalerOrientationDriver utility to make sharing UI for Landscape / Portrait easier. Read what it does carefully.

Familiarize yourself with: Auto Layout | Unity UI | 1.0.0

For your use case you just need a HorizontalLayoutGroup, and three children with LayoutElements with the correct settings.