FullScreenUITexture.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using UnityEngine;
  2. using System.Collections;
  3. public class FullScreenUITexture : MonoBehaviour
  4. {
  5. private UITexture uiTexture;
  6. private UISprite uiSprite;
  7. void Start()
  8. {
  9. uiTexture = GetComponent<UITexture>();
  10. uiSprite = GetComponent<UISprite>();
  11. if (uiTexture != null)
  12. {
  13. uiTexture.width = (int)(Screen.height * UIRoot.Instance.GetPixelSizeAdjustment(Screen.width)*1.05f);
  14. uiTexture.height = (int)(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.width) * 1.05f);
  15. }
  16. if (uiSprite != null)
  17. {
  18. uiSprite.width = (int)(Screen.height * UIRoot.Instance.GetPixelSizeAdjustment(Screen.width) * 1.05f);
  19. uiSprite.height = (int)(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.width) * 1.05f);
  20. }
  21. }
  22. void Update()
  23. {
  24. if (uiTexture != null)
  25. {
  26. uiTexture.width = (int)(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height) * 1.05f);
  27. uiTexture.height = (int)(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.width) * 1.05f);
  28. }
  29. if (uiSprite != null)
  30. {
  31. uiSprite.width = (int)(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height) * 1.05f);
  32. uiSprite.height = (int)(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.width) * 1.05f);
  33. }
  34. }
  35. }