You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

18 lines
363 B

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);
}
}
}