FitHeightToScreen.cs 452 B

12345678910111213141516
  1. using System;
  2. using UnityEngine;
  3. namespace Leap.Unity
  4. {
  5. public class FitHeightToScreen : MonoBehaviour
  6. {
  7. private void Awake()
  8. {
  9. float num = (float)(base.GetComponent<GUITexture>().texture.width / base.GetComponent<GUITexture>().texture.height);
  10. float num2 = num * (float)Screen.height;
  11. float x = ((float)Screen.width - num2) / 2f;
  12. base.GetComponent<GUITexture>().pixelInset = new Rect(x, 0f, num2, (float)Screen.height);
  13. }
  14. }
  15. }