11 ScreenOrientation orientation;
14 float screenRatio = 1.0f;
15 Vector3 and_pRot, and_puRot, and_lRot, and_lrRot;
26 var Screenheight =
_targetCam.orthographicSize * 2.0f;
27 var Screenwidth = Screenheight * Screen.width / Screen.height;
28 height = Screenheight;
30 transform.localPosition =
new Vector3(0, 0, 91.6f);
32#if UNITY_EDITOR|| UNITY_STANDALONE||UNITY_WEBGL||UNITY_WEBPLAYER
33 transform.localEulerAngles =
new Vector3(90, 180, 0);
34 transform.localScale =
new Vector3(width / 10, 1.0f, height / 10);
36 transform.localEulerAngles =
new Vector3(90,180,0);
37 transform.localScale =
new Vector3(width/10, 1.0f, height/10);
41 orientation = Screen.orientation;
42#if (UNITY_ANDROID||UNITY_IOS)&& !UNITY_EDITOR
43 updateRotationAndScale();
50 if (orientation != Screen.orientation)
52 updateRotationAndScale();
53 orientation = Screen.orientation;
58 void assignAngleVectors()
61 var devceName = SystemInfo.deviceModel;
62 if (devceName.ToLower().Contains(
"nexus") && devceName.ToLower().Contains(
"5x"))
65 and_lrRot =
new Vector3(90,180,0);
66 and_lRot =
new Vector3(-90,0,0);
67 and_pRot =
new Vector3(0,90,270);
68 and_puRot =
new Vector3(0,270,90);
70 and_lrRot =
new Vector3(-90,0,0);
71 and_lRot =
new Vector3(90,180,0);
72 and_pRot =
new Vector3(0,270,90);
73 and_puRot =
new Vector3(0,270,90);
79 and_lrRot =
new Vector3(-90,0,0);
80 and_lRot =
new Vector3(90,180,0);
81 and_pRot =
new Vector3(0,270,90);
82 and_puRot =
new Vector3(0,90,270);
84 and_lrRot =
new Vector3(90,180,0);
85 and_lRot =
new Vector3(-90,0,0);
86 and_pRot =
new Vector3(0,90,270);
87 and_puRot =
new Vector3(0,270,90);
96 var orgVec = transform.localScale;
98 transform.localScale =
new Vector3(orgVec.x, 1.0f, orgVec.z * screenRatio);
99 else if (screenRatio < 1 && screenRatio > 0)
100 transform.localScale =
new Vector3(orgVec.x / screenRatio, 1.0f, orgVec.z);
104 void updateRotationAndScale()
106 var screenHeight_1 = Screen.height;
107 var screenWidth_1 = Screen.width;
108 if (Screen.orientation == ScreenOrientation.Portrait ||
109 Screen.orientation == ScreenOrientation.PortraitUpsideDown)
111 if (screenHeight_1 < screenWidth_1)
113 var tempvalue = screenWidth_1;
114 screenWidth_1 = screenHeight_1;
115 screenHeight_1 = tempvalue;
118 var Screenheight =
_targetCam.orthographicSize * 2.0f;
119 var Screenwidth = Screenheight * screenWidth_1 / screenHeight_1;
120 height = Screenheight;
123 if( Screen.orientation == ScreenOrientation.PortraitUpsideDown)
125 transform.localEulerAngles = and_puRot;
129 transform.localEulerAngles = and_pRot;
132 transform.localScale =
new Vector3(height/10, 1.0f, width/10);
134 if( Screen.orientation == ScreenOrientation.PortraitUpsideDown)
136 transform.localEulerAngles = and_puRot;
140 transform.localEulerAngles = and_pRot;
143 transform.localScale =
new Vector3(-1*height/10, 1.0f, width/10);
146 else if (Screen.orientation == ScreenOrientation.Landscape ||
147 Screen.orientation == ScreenOrientation.LandscapeLeft)
149 if (screenHeight_1 > screenWidth_1)
151 var tempvalue = screenWidth_1;
152 screenWidth_1 = screenHeight_1;
153 screenHeight_1 = tempvalue;
156 var Screenheight =
_targetCam.orthographicSize * 2.0f;
157 var Screenwidth = Screenheight * screenWidth_1 / screenHeight_1;
158 height = Screenheight;
162 transform.localEulerAngles = and_lRot;
163 transform.localScale =
new Vector3(width/10, 1.0f, height/10);
165 transform.localEulerAngles = and_lRot;
166 transform.localScale =
new Vector3(-1*width/10, 1.0f, height/10);
169 else if (Screen.orientation == ScreenOrientation.LandscapeRight)
171 if (screenHeight_1 > screenWidth_1)
173 var tempvalue = screenWidth_1;
174 screenWidth_1 = screenHeight_1;
175 screenHeight_1 = tempvalue;
178 var Screenheight =
_targetCam.orthographicSize * 2.0f;
179 var Screenwidth = Screenheight * screenWidth_1 / screenHeight_1;
180 height = Screenheight;
183 transform.localEulerAngles = and_lrRot;
184 transform.localScale =
new Vector3(width/10, 1.0f, height/10);
186 transform.localEulerAngles = and_lrRot;
187 transform.localScale =
new Vector3(-1*width/10, 1.0f, height/10);
void correctPlaneScale(float size)