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.

27 lines
867 B

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