public void ApplyChange()
{
if (scaleMode == ScaleMode.ScaleWithScreenSize)
{
if (designResolutionX == 0 || designResolutionY == 0)
return;
int dx = designResolutionX;
int dy = designResolutionY;
if (Screen.width > Screen.height && dx < dy || Screen.width < Screen.height && dx > dy)
{
//scale should not change when orientation change
int tmp = dx;
dx = dy;
dy = tmp;
}
if (screenMatchMode == ScreenMatchMode.MatchWidthOrHeight)
{
float s1 = (float)Screen.width / dx;
float s2 = (float)Screen.height / dy;
scaleFactor = Mathf.Min(s1, s2);
}
else if (screenMatchMode == ScreenMatchMode.MatchWidth)
scaleFactor = (float)Screen.width / dx;
else
scaleFactor = (float)Screen.height / dy;
}
else if (scaleMode == ScaleMode.ConstantPhysicalSize)
{
float dpi = Screen.dpi;
if (dpi == 0)
dpi = fallbackScreenDPI;
if (dpi == 0)
dpi = 96;
scaleFactor = dpi / (defaultSpriteDPI == 0 ? 96 : defaultSpriteDPI);
}
else
scaleFactor = constantScaleFactor;
StageCamera.screenSizeVer++;
}