123456789101112131415161718192021222324252627282930313233343536 |
- 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<RectTransform>().localScale = new Vector3(w, w * (1080f / 1920f), 1);
- }
- else
- {
- this.GetComponent<RectTransform>().localScale = new Vector3(h * (1920f / 1080f), h, 1);
- }
- }
- }
- }
|