Resizing UI Image but with minimum width

I have a dialog box I want to fit the bottom of the screen such that there’s a certain amount of space on either side, this I can do easily using a stretchy rect transform.

However, I want this box to always be at least a certain width and for this minimum width to “override” the rect transform’s settings as the screen’s aspect ratio changes. So for example, if the screen is >1000 pixels wide, there is always 200 pixels of space on either side of the UI image. However once it is <1000, it remains fixed at 600 pixels wide.

I think it has something to do with using a Layout Group and a Content Size Fitter with the “min size” setting but I’m not sure exactly how to arrange the hierarchy.

Thanks.

Answering my own question:

Horizontal layout group with child control size and child force expand both set for width, three children. Two empty gameobjects to the left and right of the box, and the box itself in the middle with a layout element and the min width set to the desired width. Works nicely.

solved
I examined it .

YourImageOrRaw image .GetComponent<RectTransform>().sizeDelta = new Vector2( minWidth, minHeight);

Don't forget it >using UnityEngine.UI;