UIOrthoCamera.cs 710 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using UnityEngine;
  3. [ExecuteInEditMode]
  4. [RequireComponent(typeof(Camera))]
  5. [AddComponentMenu("NGUI/UI/Orthographic Camera")]
  6. public class UIOrthoCamera : MonoBehaviour
  7. {
  8. private void Start()
  9. {
  10. this.mCam = base.GetComponent<Camera>();
  11. this.mTrans = base.transform;
  12. this.mCam.orthographic = true;
  13. }
  14. private void Update()
  15. {
  16. float num = this.mCam.rect.yMin * (float)UICamera.ScreenHeight;
  17. float num2 = this.mCam.rect.yMax * (float)UICamera.ScreenHeight;
  18. float num3 = (num2 - num) * 0.5f * this.mTrans.lossyScale.y;
  19. if (!Mathf.Approximately(this.mCam.orthographicSize, num3))
  20. {
  21. this.mCam.orthographicSize = num3;
  22. }
  23. }
  24. private Camera mCam;
  25. private Transform mTrans;
  26. }