using System.Collections; using System.Collections.Generic; using UnityEngine; public class UIBG : MonoBehaviour { // Start is called before the first frame update void Start() { StartCoroutine("check"); } float w; float h; IEnumerator check() { while (true) { yield return new WaitForSeconds(1); w = Screen.width; h = Screen.height; if((float)((float)w/(float)h)<1920f/1080f) { this.GetComponent().localScale = new Vector3(w, w * (1080f / 1920f), 1); } else { this.GetComponent().localScale = new Vector3(h * (1920f / 1080f), h, 1); } } } }