Fixed height with scaled width for UI panel [Unity] - unity3d

I have to make 2 panels on the bottom of the UI. The bottom left panel needs to stay at a fixed square size regardless of the game window size. The bottom right panel needs to keep a fixed height but expand the width to fill all the space in between the bottom left panel and right of the game window.
This green panel should remain a constant sized square, while the blue panel needs to expand its width but not its height when the game window is resized.
I've tried separating them into two different canvas', and using a horizontal layout group, but I can't get what I'm looking for. The closest I've gotten is with a single canvas that doesn't scale (constant pixel size), and a horizontal layout group that has the blue panel at a maximum width for my display resolution. This leads to the blue panel just going off screen when the game window is downsized, but I need it to fit exactly to the window.

Green:
Blue:
Canvas (notice Match set to 1):
I hope it gives the result you were looking for

Adding to #slowikowskiarkadiusz answer, I was able to get my intended result by following all of these steps, except I used Constant Pixel Size for the canvas scaler. The anchor points of the blue panel allow it to still expand width, but constant pixel size kept the height constant.

Related

Responsive in Unity 2D

I want my Unity 2d game responsive in all android mobile device. So i anchor 4 canvas to 4 edge (top left, top right, bottom left, bottom right).
But when i change a device, the size of each component is not change. Now i want the size of each component change depend on each resolution of device. What should i do or what tutorial i can follow.
Problem will come when i get small screensize, it like this
Canvas Scaler
You can solve it using Canvas Scaler.
You can find various options in the list in UI Scale Mode.
When selecting the option to fit the commonly used screen size,
If you want to align UI elements to the height, set Match, an element of Screen Math Mode, to Height, and if you want both height and width to match, place it in the center.

How can I lay out the following screen in flutter

I am new to Flutter and trying to convert my iOS app to Flutter. However, I am having difficulty laying out the screen. Below is what the iOS screen looks like. I keep on getting red screens with layout errors saying it cannot layout the screen. When I add a column and add to that an image and a horizontally scrolling grid in Flutter I get the layout errors. How can I layout this screen?
I think it should have a column as the main widget. Then, a large image should be displayed, which displays centered width-wise on the screen. It should be constrained height-wise and wide enough not to distort the image. The photos come in a variety of heights and widths.
Then there should be a large text field centered width-wise in the central column. Then a breed text box is centered width-wise in the central column and followed by a line of stats—lastly, a city, state, and miles.
Then a centered list of icons with a single line of text-centered underneath each icon. Finally, the whole icon bar should be centered width-wise in the column.
Next, there should be a line of small photos of the cat, which is left aligned to the column and fills to the right going off-screen and scrollable horizontally. It should be a grid with a staggered layout width-wise. Each image should be a fixed height and a ratio of width to fixed height to fit the image without distorting it. The images should have rounded corners. The width and height of the source image are known ahead of time and need to be adjusted to fit the new fixed height.
Lastly, there should be a web browser that fills the width of the column with a height large enough to hold the content of the HTML without scrolling the web browser so the whole screen looks like it is one screen.
The whole screen should be able to scroll vertically but not horizontally to see the main column's total content.
Below is what the screen should look like:

Setting X of camera's viewport causes the black strip to be rendered

I’ve run out of ideas, please help me.
That's the situation:
Imagine a simple object in the center of screen (it's always so, because camera has an orbit script)
Then we add a canvas image, 300px width, for example, on the right side of the screen (blue one in the picture). Our cube is not centered anymore.
For example, we can change X property of camera viewport rect, but we'll get a black strip and if object appears in this zone, it would not be rendered.
So, what can I do to offset camera position?
Thank you in advance!
The best option I have for now is:
create basic UI for FullHD resolution and make right panel as wide as black strip is
if user's screen bigger than 1920px, than change Canvas Scaler mode from Constant pixel size to Scale with screen size

Unity UI elements with different resolution

I have added an image as a canvas child, the image is just a layout to outfit UI text elements like in below image.
here the black outline is the image and red one is their bounds which we can see in editor, the blue text is UI Text element with anchor preset bottom stretch and right = 100. The canvas render mode is screen overlay, scale with screen size, reference resolution is 1920x1080. Thus in image 1, the UI text is in middle, but in image 2 (different resolution) it does't look like in middle.
You need to set Text anchor preset to bottom-center to achieve that Text is always in the middle-bottom of the screen.
This manual is a great Instruction of how you can position UI elements relative to the Canvas and each other.

Perfect square buttons in Unity3d

I'm trying to create a flexible menu for my mobile project but i'm having trouble with new UI system. I could do this with code but i want to know if it's possible without coding.
Here is what i'm trying to do:
http://i.imgur.com/33yMRgV.jpg
Basically, i want to have a menu area with height of %10 of total screen height. So for example, if it's a HD device, i want height of the red area in the image to be 192 pixel (1920/10). I can do that easily but i also want to have 192x192 buttons aligned on top right corner. I can set the height to parent so it becomes 192 too but i can't set the width to height. I can use ratio fitter to make them squares but i can't place them side by side.
So basically i just want to set width of an element to it's height and puting them side by side without coding. Is it possible?
Thanks
Have a panel inside Canvas, and add horizontal layout group and then add your buttons inside this panel.
Note : You will need to increase the width of the panel more than the canvas in order to have buttons horizontally.