using UnityEngine; using System.Collections; public class WidthUITexture : MonoBehaviour { private UITexture uiTexture; private UISprite uiSprite; void Start() { uiTexture = GetComponent(); uiSprite = GetComponent(); 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)); } } }