FollowUI.cs 509 B

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