Newer
Older
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; //andr
using UnityEngine.SceneManagement;
using System.IO; //
using UnityEngine.Video;//streaming
using UnityEngine.Networking;
//using static StreamingAssetLoader;
//using static CheckServer;
//using static CommunicationEvents;
using static UIconfig;
using static StreamingAssetLoader;
using static CommunicationEvents;
public class StartMenue_mobile : MonoBehaviour
{
//public int myUI_ID;
public GameObject myself_GObj;
//public GameObject parent_GObj;
//public int backUI_ID;
//public int optionsUI_ID;
//public int failedUI_ID;
public GameObject child1_GObj;
public Texture2D cursorArrow_35;
public Texture2D cursorArrow_50;
public Texture2D cursorArrow_60;
public Texture2D cursorArrow_70;
public Texture2D cursorArrow_100;
public Texture2D cursorArrow_140;
public Texture2D cursorArrow_200;
public Texture2D cursorArrow_300;
public Text GObj_text;
Stefan Richter
committed
private void Awake()
toChild1();
Stefan Richter
committed
if (checkOperationSystemAlreadyDone == false)
{
start2_CheckOS_CheckConfig();
checkOperationSystemAlreadyDone = true;
}
GObj_text.text = CommunicationEvents.Opsys + "";
Stefan Richter
committed
CheckServerA[1] = 1;
CheckServerA[2] = 1;
CheckServerA[3] = 1;
}
void Start()
{
}
void start2_CheckOS_CheckConfig()
{
switch (CommunicationEvents.Opsys)
if (!checkPDP())
{
ResetStreamingAsset();
UIconfig.controlMode = CommunicationEvents.Opsys + 1;
NetworkJSON_Save();
}
NetworkJSON_Load();
checkOS();
ResetDataPath();
setMouse();
break;
case 1:
UIconfig.controlMode = CommunicationEvents.Opsys + 1;
NetworkJSON_Save();
}
NetworkJSON_Load();
checkOS();
ResetDataPath();
setMouse();
break;
default:
setMouse();
if (!checkPDP())
{
ResetStreamingAsset();
UIconfig.controlMode = CommunicationEvents.Opsys + 1;
NetworkJSON_Save();
}
NetworkJSON_Load();
checkOS();
setMouse();
break;
}
}
private void Update()
{
}
void checkOS()
{
if (CommunicationEvents.autoOSrecognition == true) {
checkOS2();
}
else
{
//CommunicationEvents.Opsys = CommunicationEvents.Opsys_Default;
Stefan Richter
committed
if(Opsys == 1)
{
ServerAutoStart = false;
}
}
void checkOS2()
{
//https://docs.unity3d.com/ScriptReference/RuntimePlatform.html
if (Application.platform == RuntimePlatform.WindowsPlayer)
{
Debug.Log("Windows OS detected");
CommunicationEvents.Opsys = 0;
Stefan Richter
committed
return;
}
if (Application.platform == RuntimePlatform.Android)
{
Debug.Log("Android OS detected");
CommunicationEvents.Opsys = 1;
Stefan Richter
committed
return;
}
//Default:
//CommunicationEvents.Opsys = CommunicationEvents.Opsys_Default;
return;
}
public void setMouse()
print("OPSYS: " + CommunicationEvents.Opsys);
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
if (CommunicationEvents.Opsys == 1)
{
CommunicationEvents.CursorVisDefault = false;
Cursor.visible = false;
}else
{
Cursor.visible = true;
CommunicationEvents.CursorVisDefault = true;
}
//Android crashes in level scene;
if (CommunicationEvents.Opsys != 1) {
double curssz = 1 / (UIconfig.cursorSize);
// print(UIconfig.cursorSize);
if (UIconfig.screWidth / 35 < curssz)
{
Cursor.SetCursor(cursorArrow_35, Vector2.zero, CursorMode.ForceSoftware);
print("m35");
}
else
{
if (UIconfig.screWidth / 50 < curssz)
{
Cursor.SetCursor(cursorArrow_50, Vector2.zero, CursorMode.ForceSoftware);
print("m50");
}
else
{
if (UIconfig.screWidth / 60 < curssz)
{
Cursor.SetCursor(cursorArrow_60, Vector2.zero, CursorMode.ForceSoftware);
print("m60");
}
else
{
if (UIconfig.screWidth / 70 < curssz)
{
Cursor.SetCursor(cursorArrow_70, Vector2.zero, CursorMode.ForceSoftware);
print("m70");
}
else
{
if (UIconfig.screWidth / 100 < curssz)
{
Cursor.SetCursor(cursorArrow_100, Vector2.zero, CursorMode.ForceSoftware);
print("m100");
}
else
{
if (UIconfig.screWidth / 140 < curssz)
{
Cursor.SetCursor(cursorArrow_140, Vector2.zero, CursorMode.ForceSoftware);
print("m140");
}
else
{
if (UIconfig.screWidth / 200 < curssz)
{
Cursor.SetCursor(cursorArrow_200, Vector2.zero, CursorMode.ForceSoftware);
print("m200");
}
else
{
Cursor.SetCursor(cursorArrow_300, Vector2.zero, CursorMode.ForceSoftware);
print("m300");
}
}
}
}
}
}
}
}
}
void ScreenOptimization()
{
Screen.orientation = ScreenOrientation.LandscapeLeft;
UIconfig.screHeight = Screen.height;
UIconfig.screWidth = Screen.width;
CommunicationEvents.lastIP = CommunicationEvents.selecIP;
/* //ScreenMatchMode.MatchWidthOrHeight:
// If one axis has twice resolution and the other has half, it should even out if widthOrHeight value is at 0.5.
// In normal space the average would be (0.5 + 2) / 2 = 1.25
// In logarithmic space the average is (-1 + 1) / 2 = 0
float scaleFactor = Mathf.Max(screenSize.x / m_ReferenceResolution.x, screenSize.y / m_ReferenceResolution.y);
float logWidth = Mathf.Log(screenSize.x / m_ReferenceResolution.x, kLogBase);
float logHeight = Mathf.Log(screenSize.y / m_ReferenceResolution.y, kLogBase);
float logWeightedAverage = Mathf.Lerp(logWidth, logHeight, m_MatchWidthOrHeight);
scaleFactor = Mathf.Pow(kLogBase, logWeightedAverage);
//GameObject.Find("ASMenue").GetComponent;
//Camera;
//mainInputField.text = "Enter IP Here...";
*/
UnityEngine.UI.CanvasScaler c = myself_GObj.GetComponent<UnityEngine.UI.CanvasScaler>();
c.uiScaleMode = UnityEngine.UI.CanvasScaler.ScaleMode.ScaleWithScreenSize;
UIconfig.refWidth = (int)Mathf.Round(c.referenceResolution[0]);
UIconfig.refHeight = (int)Mathf.Round(c.referenceResolution[1]);
//CommunicationEvents.scaleMatch = 0.5f;
/*
//float kLogBase=10;
//CommunicationEvents.scaleMatch = Mathf.Max(CommunicationEvents.screWidth / CommunicationEvents.refWidth, CommunicationEvents.screHeight / CommunicationEvents.refHeight);
//float logWidth = Mathf.Log(CommunicationEvents.screWidth / CommunicationEvents.refWidth, kLogBase);
//float logHeight = Mathf.Log(CommunicationEvents.screHeight / CommunicationEvents.refHeight, kLogBase);
//float logWeightedAverage = Mathf.Lerp(logWidth, logHeight, 0.5f);
//CommunicationEvents.scaleMatch = Mathf.Pow(kLogBase, logWeightedAverage);
//c.matchWidthOrHeight = CommunicationEvents.scaleMatch;
/*
RectTransform rt = GetComponent<RectTransform>();
Vector3 screenSize = Camera.main.ViewportToWorldPoint(Vector3.up + Vector3.right);
screenSize *= 02;
float sizeY = screenSize.y / rt.rect.height;
float sizeX = screenSize.x / rt.rect.width;
rt.localScale = new Vector3(sizeX, sizeY, 1);
*/
}
public void toChild1()
{
ClearUIC();
UIconfig.Andr_Start_menue_counter = 1;
child1_GObj.SetActive(true); ;
}
/// <summary>
/// Deactivates all Pages.
/// </summary>
private void ClearUIC()
{
for (int i = 0; i < myself_GObj.transform.childCount; i++)
{
myself_GObj.transform.GetChild(i).gameObject.SetActive(false);
}
}