123456789101112131415161718192021222324252627282930313233343536373839 |
- using UnityEngine;
- using System.Collections;
- public class WidthUITexture : MonoBehaviour {
- private UITexture uiTexture;
- private UISprite uiSprite;
- void Start()
- {
- uiTexture = GetComponent<UITexture>();
- uiSprite = GetComponent<UISprite>();
- if (uiTexture != null && UIRoot.Instance != null)
- {
- uiTexture.width = (int)(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height));
-
- }
- if (uiSprite != null)
- {
- uiSprite.width = (int)(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height));
-
- }
- }
- void Update()
- {
- if (uiTexture != null)
- {
- uiTexture.width = (int)(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height));
- }
- if (uiSprite != null)
- {
- uiSprite.width = (int)(Screen.width * UIRoot.Instance.GetPixelSizeAdjustment(Screen.height));
- }
- }
- }
|