Read an article in Cnblogs, finally understand the Unity2d camera system: http://www.cnblogs.com/flyFreeZn/p/4073655.html
According to his plan, I rewrote two adaptation schemes: FixedWidth and Fixedheight, which is to lock one of the variables to fit the screen.
1 usingUnityengine;2 usingSystem.Collections;3 4 Public classGamecamera:monobehaviour {5 Public stringScaleMode ="fixedwidth";6 7 Public floatDesignwidth =9.6f;8 Public floatDesignheight =16f;9 Ten //Use this for initialization One voidStart () { A floatAspectratio = Screen.width *1.0f/Screen.height; - floatOrthographicsize =0; - the Switch(scaleMode) { - Case "fixedwidth": -Orthographicsize = Designwidth/(2*aspectratio); - Break; + Case "fixedheight": -Orthographicsize = designheight/2; + Break; A } at - This. Getcomponent<camera> (). Orthographicsize =orthographicsize; - Debug.Log (orthographicsize); - } - - //Update is called once per frame in voidUpdate () { - to } +}
You can modify the design size and remember that the design size is scaled by 1:100 scale.
Unity2d screen Adaptation Scheme