ScreenFill.cs 978 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using UnityEngine;
  2. [ExecuteInEditMode]
  3. public class ScreenFill : MonoBehaviour
  4. {
  5. private UITexture texture;
  6. public UITexture UITexture
  7. {
  8. get
  9. {
  10. if (!texture)
  11. {
  12. texture = GetComponent<UITexture>();
  13. }
  14. return texture;
  15. }
  16. }
  17. public bool Normal = false;
  18. // Use this for initialization
  19. void Start () {
  20. if (Normal)
  21. {
  22. UITexture.width = Screen.width;
  23. UITexture.height = Screen.height;
  24. }
  25. else
  26. {
  27. UITexture.width = Screen.height;
  28. UITexture.height = Screen.width;
  29. }
  30. }
  31. // Update is called once per frame
  32. void Update () {
  33. if (Normal)
  34. {
  35. UITexture.width = Screen.width;
  36. UITexture.height = Screen.height;
  37. }
  38. else
  39. {
  40. UITexture.width = Screen.height;
  41. UITexture.height = Screen.width;
  42. }
  43. }
  44. }