12345678910111213141516171819202122232425262728 |
- using UnityEngine;
- using System.Collections;
- /// <summary>
- /// This component is responsible for keeping the width always the same, so that the player
- /// will not have more reaction time if he plays on an iPhone 5 (which is 16:9), compared
- /// to iPad (which is 4:3)
- /// </summary>
- public class AspectRatioFixer : MonoBehaviour
- {
- UIRoot uiRoot;
- private static float _scaleChange;
- private static int _uiManualHeight;
- public static float ScaleChange { get { return _scaleChange; } }
- public static int UIManualHeight { get { return _uiManualHeight; } }
- void Awake()
- {
- uiRoot = GetComponent<UIRoot>();
- float previousManualHeight = uiRoot.manualHeight;
- uiRoot.manualHeight = (int)((GameConstants.GAME_WIDTH / (float)Screen.width) * Screen.height);
- _scaleChange = uiRoot.manualHeight / previousManualHeight;
- _uiManualHeight = uiRoot.manualHeight;
- }
- }
|