using UnityEngine;
using System.Collections;
public class CameraReSize : MonoBehaviour {
public UILabel kLog = null;
void Start()
{
ReSizingOrthographic(camera);
/*
if ( null != kLog )
kLog.text = "";
string _Log = "";
_Log += string.Format("Screen Size {0}/{1}\n", Screen.width, Screen.height);
_Log += string.Format("Size : {0}\n", camera.orthographicSize);
if (null != kLog)
kLog.text = _Log;
*/
}
void ReSizingOrthographic(Camera _Camera)
{
Camera getCam = _Camera;
if (null == getCam)
return;
if( true == getCam.isOrthoGraphic )
{
int W = Screen.width;
int H = Screen.height;
int FixW = 1280;
int FixH = 720;
float fWidth = (float)FixW / (float)W;
float fHeight = (float)FixH / (float)H;
getCam.orthographicSize = fWidth / fHeight;
}
else
{
/* 이건 많은 테스트가 필요함 ; */
int W = Screen.width;
int H = Screen.height;
int FixW = 1280;
int FixH = 720;
float fWidth = (float)FixW / (float)W;
float fHeight = (float)FixH / (float)H;
float fValue = fWidth / fHeight;
getCam.fieldOfView = getCam.fieldOfView * fValue;
}
return;
{
float fWidth = (float)Screen.width;
float fheight = (float)Screen.height;
float fValue = fWidth / fheight;
Debug.Log("Screen Size- " + fWidth + " / " + fheight);
#if UNITY_IPHONE
string getStr = string.Format("{0:0.000}", fValue);
if (0 == getStr.CompareTo("1.333"))
fValue = 1.25f;
else if (0 == getStr.CompareTo("1.500"))
fValue = 1.1f;
else if (0 == getStr.CompareTo("1.775"))
fValue = 0.98f;
#else
float fWantValue = 1280.0f / 720.0f; // 1.77777779f
fValue = 1.0f + fWantValue - fValue;// 1 + 1.77777779f - 1.116667 = 1.07
if (1.0f > fValue)
fValue = 1.0f;
#endif
Debug.Log(" : ReSizingOrthographic - " +
getCam.orthographicSize +
" / " +
(getCam.orthographicSize * fValue));
getCam.orthographicSize *= fValue;
}
}
}
출저 : http://blog.naver.com/kstarghost/70179554228