using UnityEngine; using System.Collections; public class RootPanelScaler : MonoBehaviour { public const int ORIGIN_WIDTH = 560; public const int ORIGIN_HEIGHT = 420; public const int ORIGIN_BATTLE_HEIGHT = 480; // Use this for initialization void Awake () { float height = 0; if(GameObject.FindObjectOfType() != null) height = ORIGIN_BATTLE_HEIGHT; else height = ORIGIN_HEIGHT; float s = (float)Screen.height/height; RectTransform rectTrans = GetComponent(); rectTrans.localScale = new Vector3(s, s, 1f); float width = Screen.width/s; rectTrans.sizeDelta = new Vector2(width, height); } }