using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class AdaptiveResolution : MonoBehaviour { // Start is called before the first frame update private RawImage image; private float startWidth,startHeight; private int currentWidth, currentHeight; void Start() { image = GetComponent(); startWidth = image.rectTransform.rect.width; startHeight= image.rectTransform.rect.height; } // Update is called once per frame void Update() { currentWidth = (int)((1080.0f / Screen.height) * startWidth); currentHeight= (int)((1080.0f / Screen.height) * startHeight); // image.rectTransform.sizeDelta(currentWidth, currentHeight); image.rectTransform.sizeDelta = new Vector2(currentWidth, currentHeight); } }