123456789101112131415161718192021222324252627282930 |
- 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<BattleController>() != null)
- height = ORIGIN_BATTLE_HEIGHT;
- else
- height = ORIGIN_HEIGHT;
- float s = (float)Screen.height/height;
- RectTransform rectTrans = GetComponent<RectTransform>();
- rectTrans.localScale = new Vector3(s, s, 1f);
- float width = Screen.width/s;
- rectTrans.sizeDelta = new Vector2(width, height);
- }
- }
|