BGUICheck.cs 565 B

12345678910111213141516171819
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. [ExecuteInEditMode]
  6. public class BGUICheck : MonoBehaviour
  7. {
  8. // Update is called once per frame
  9. void Update()
  10. {
  11. float bl2 = (float)Screen.height / this.GetComponent<RawImage>().texture.height;
  12. this.GetComponent<RectTransform>().sizeDelta = new Vector2(this.GetComponent<RawImage>().texture.width, this.GetComponent<RawImage>().texture.height);
  13. this.transform.localScale = new Vector3(bl2, bl2, bl2);
  14. }
  15. }