I have a game that works great on mobiles and scales perfectly however for tablets it scales too wide. I tried adding some code to the canvas to limit it’s width but I am guessing the canvas scaler is overriding this. Is there anyway to limit the canvas width and have it appear in the middle of the screen on tablets so that the aspect ratio is preserved
public void resizer()
{
RectTransform objectRectTransform = gameObject.GetComponent<RectTransform>();
float testheight = objectRectTransform.rect.height / objectRectTransform.rect.width;
if (testheight < 1.7) {
gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2 (70, 100);
}
}