using UnityEngine; namespace Utils { public class UiFitScale : MonoBehaviour { [SerializeField] private float _width; [SerializeField] private float _height; private void Awake() { var coof = _width / _height; var newCoof = Screen.width / (float) Screen.height; transform.localScale = Vector3.one * Mathf.Min(1, coof / newCoof); } } }