![]()
I think I really have a big trouble…
I want to make a cross-platform game, then different platform have different resolution ratio for sure…
and when I use a camera with orthographic projection, I can’t show my game correct…
I don’t have a very clear concept of the parameter “orthographicSize”, what does it really mean?
and I can’t just get a algorithm to adjust orthographicSize to make my game fit visible on each resolution ratio
(for example:1024x768, 960x640,800x600, 480x320,1136x640,etc)
thank you!
and my question is:
is there a script that adjust the orthographic camera to adapt different resolution ratios?and maybe a package, or any
reference related…
thanks~
well unity automatically handles multiple resolutions to a degree.
What exactly do you want to do?
slow down and have a pray…don’t be nervous…
have a deep breath…
yeah, I think I really have a big trouble…
I want to make a cross-platform game, then different platform have different resolution ratio for sure…
and when I use a camera with orthographic projection, I can’t show my game correct…
I don’t have a very clear concept of the parameter “orthographicSize”, what does it really mean?
and I can’t just get a algorithm to adjust orthographicSize to make my game fit visible on each resolution ratio
(for example:1024x768, 960x640,800x600, 480x320,1136x640,etc)
thank you!
and my question is:
is there a script that adjust the orthographic camera to adapt different resolution ratios?and maybe a package, or any
reference related…
thanks~
I think most, if not all those resolution settings exist in the editor. Look at your game tab. There is a drop down menu to set the resolution.
er…I got the answer…
and I have made a terrible mistake…
and here is my answer, I got the idea from cocos2d-x
mainCamera = GetComponent ();
// float allScreenShowHeight = Screen.height/oneUnityUnitPixel/2.0f;
//// float nativeResolutionWidth =
float m_fScaleX = Screen.width *1.0f / nativeResolutionWidth;
float m_fScaleY = Screen.height *1.0f / nativeResolutionHeight;
// scaleX =
// float nativeAspect = (float)nativeResolutionWidth / nativeResolutionHeight;
float currentAspect = Screen.width*1.0f / Screen.height;
if (m_fScaleX > m_fScaleY)
{
// s = pixelWidth / nativeResolutionWidth;
mainCamera.orthographicSize = nativeResolutionHeight / 2.0f / oneUnityUnitPixel;
}
else
{
mainCamera.orthographicSize = nativeResolutionWidth/oneUnityUnitPixel*(1.0f/currentAspect)/2.0f;
}