using UnityEngine;
using System.Collections;
public class CorrectForDevice : MonoBehaviour
{
public UIAtlas referenceAtlas;
private UIRoot uIRoot;
private ScreenOrientation currentOrientation;
private bool initialized = false;
private float resolutionScale = 1f;
void Awake()
{
uIRoot = GetComponent<UIRoot>();
if( iPhone.generation == iPhoneGeneration.Unknown )
{
referenceAtlas.replacement = Resources.Load<GameObject>( "iPadRetina" ).GetComponent<UIAtlas>();
resolutionScale = 0.5f;
}
if( iPhone.generation == iPhoneGeneration.iPhone5 )
{
referenceAtlas.replacement = Resources.Load<GameObject>( "iPhone" ).GetComponent<UIAtlas>();
}
}
void Start()
{
currentOrientation = Screen.orientation;
}
void Update()
{
if( !initialized )
{
SetHeight();
initialized = true;
}
if( Screen.orientation != currentOrientation )
{
SetHeight();
}
}
private void SetHeight()
{
uIRoot.manualHeight = (int)((float)Screen.currentResolution.height * resolutionScale);
currentOrientation = Screen.orientation;
}
}