Newer
Older
using UnityEngine;
using UnityEngine.SceneManagement;
using static CommunicationEvents;
using static UIconfig;
using static Restart;
Stefan Richter
committed
using System.Collections;
public class HideUI_mobile : MonoBehaviour
{
//public KeyCode Key = KeyCode.F1;
//public KeyCode visMouse = KeyCode.LeftControl;
//public KeyCode ScreenshotKey = KeyCode.F12;
public string
modifier,
modundo,
modredo,
modreset,
modsave,
modload;
public string toolMode_keyBind;
public string MathMode_keyBind;
public string cancel_keyBind;
Stefan Richter
committed
public float waitingBetweenInputs = 0.2f;
public UnityStandardAssets.Characters.FirstPerson.FirstPersonController CamControl_StdAsset;
public Characters.FirstPerson.FirstPersonController1 CamControl_ScriptChar;
public bool LockOnly = true;
public MeshRenderer CursorRenderer;
Stefan Richter
committed
private double numinputtrigger=0;
internal Canvas UICanvas;
Stefan Richter
committed
private ControlMapping input_ControlMapping;
private void Awake()
{
//New InputSystem
input_ControlMapping = new ControlMapping();
input_ControlMapping.Actionmap1.Cancel.Enable();
input_ControlMapping.Actionmap1.ToolMode.Enable();
input_ControlMapping.Actionmap1.MathMode.Enable();
input_ControlMapping.Actionmap1.Modifier.Enable();
input_ControlMapping.Actionmap1.Load.Enable();
input_ControlMapping.Actionmap1.Save.Enable();
input_ControlMapping.Actionmap1.Reset.Enable();
input_ControlMapping.Actionmap1.Undo.Enable();
input_ControlMapping.Actionmap1.Redo.Enable();
Stefan Richter
committed
}
private void OnEnable()
{
input_ControlMapping.Actionmap1.Cancel.Enable();
input_ControlMapping.Actionmap1.ToolMode.Enable();
input_ControlMapping.Actionmap1.MathMode.Enable();
input_ControlMapping.Actionmap1.Modifier.Enable();
input_ControlMapping.Actionmap1.Load.Enable();
input_ControlMapping.Actionmap1.Save.Enable();
input_ControlMapping.Actionmap1.Reset.Enable();
input_ControlMapping.Actionmap1.Undo.Enable();
input_ControlMapping.Actionmap1.Redo.Enable();
Stefan Richter
committed
}
private void OnDisable()
{
input_ControlMapping.Actionmap1.Cancel.Disable();
input_ControlMapping.Actionmap1.ToolMode.Disable();
input_ControlMapping.Actionmap1.MathMode.Disable();
input_ControlMapping.Actionmap1.Modifier.Enable();
input_ControlMapping.Actionmap1.Load.Disable();
input_ControlMapping.Actionmap1.Save.Disable();
input_ControlMapping.Actionmap1.Reset.Disable();
input_ControlMapping.Actionmap1.Undo.Disable();
input_ControlMapping.Actionmap1.Redo.Disable();
Stefan Richter
committed
}
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
void Start()
{
if (UIconfig.FrameITUIversion == 2) // 1= FrameITUI; 2= FrameITUI_mobil
{
Start2();
}
else
{
if (UICanvas == null)
{
UICanvas = GetComponentInChildren<Canvas>();
}
UICanvas.enabled = false;
}
}
void Start2()
{
if (!LockOnly)
{
if (UICanvas == null)
{
UICanvas = GetComponentInChildren<Canvas>();
}
bool camActive;
camActive = false;
UICanvas.enabled = camActive;
//CamControl.enabled = false;
//CursorRenderer.enabled = true;
SetCamControl123(false);
SetCursorRenderer123(true);
}
//}
//Start3();
//CamControl.enabled = true;
Stefan Richter
committed
StartCoroutine(slowInput());
}
void Start3()
{
print("Start3");
UIconfig.CanvasOnOff_Array[14] = 1;
UIconfig.CanvasOnOff_Array[20] = 0;
//setUI_Vis_walk(0);
//UIconfig.CanvasOnOff_Array[20] = 0;
Update();
//CheckUI_Vis_walk();
UIconfig.CanvasOnOff_Array[14] = 0;
UIconfig.CanvasOnOff_Array[20] = 1;
UIconfig.CanvasOnOff_Array[10] = 1;
UIconfig.CanvasOnOff_Array[3] = 1;
SetCamControl123(false);
}
// Update is called once per frame
void Update()
{
Stefan Richter
committed
if (UIconfig.FrameITUIversion == 2)
{
Update3();
}
Stefan Richter
committed
//print("dada" + UIconfig.CanvasOnOff_Array[4]);
}
public void HudButton()
{
Update3();
}
void Update3()
{
CheckUI_Vis_walk();
CheckIf();
CheckUI_Vis();
}
void CheckUI_Vis_walk()
{
int uiccm=0;
switch (UIconfig.controlMode)
{
case ControlMode.Keyboard:
uiccm = 0;
break;
case ControlMode.Mobile:
uiccm = 1;
break;
default:
uiccm = 0;
break;
}
UIconfig.CanvasOnOff_Array[11] = uiccm;
UIconfig.CanvasOnOff_Array[12] = uiccm;
UIconfig.CanvasOnOff_Array[13] = uiccm;
UIconfig.CanvasOnOff_Array[15] = uiccm;
UIconfig.CanvasOnOff_Array[17] = uiccm;
UIconfig.CanvasOnOff_Array[18] = uiccm;
}
void setUI_Vis_walk(int a)
{
int uiccm = a;
UIconfig.CanvasOnOff_Array[11] = uiccm;
UIconfig.CanvasOnOff_Array[12] = uiccm;
UIconfig.CanvasOnOff_Array[13] = uiccm;
UIconfig.CanvasOnOff_Array[15] = uiccm;
UIconfig.CanvasOnOff_Array[17] = uiccm;
UIconfig.CanvasOnOff_Array[18] = uiccm;
}
Stefan Richter
committed
IEnumerator slowInput()
{
yield return new WaitForSecondsRealtime(waitingBetweenInputs);
numinputtrigger = 0;
yield return null;
}
void CheckIf()
{
//walking
if (UIconfig.CanvasOnOff_Array[10] == 1 && UIconfig.CanvasOnOff_Array[20] == 1 && UIconfig.CanvasOnOff_Array[14] == 0)
{
if (UIconfig.InputManagerVersion == 1)
{
if (Input.GetButtonDown(toolMode_keyBind))
{
UIconfig.CanvasOnOff_Array[14] = 1;
UIconfig.CanvasOnOff_Array[20] = 0;
}
if (Input.GetButtonDown(MathMode_keyBind))
{
UIconfig.CanvasOnOff_Array[16] = 1;
UIconfig.CanvasOnOff_Array[20] = 0;
}
if (Input.GetButtonDown(cancel_keyBind))
{
UIconfig.CanvasOnOff_Array[02] = 1;
UIconfig.CanvasOnOff_Array[10] = 0;
return;
}
return;
Stefan Richter
committed
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
if (UIconfig.InputManagerVersion == 2 && numinputtrigger==0)
{
if (input_ControlMapping.Actionmap1.ToolMode.ReadValue<float>() != 0)
{
UIconfig.CanvasOnOff_Array[14] = 1;
UIconfig.CanvasOnOff_Array[20] = 0;
numinputtrigger++;
StartCoroutine(slowInput());
return;
}
if (input_ControlMapping.Actionmap1.MathMode.ReadValue<float>() != 0)
{
UIconfig.CanvasOnOff_Array[16] = 1;
UIconfig.CanvasOnOff_Array[20] = 0;
numinputtrigger++;
StartCoroutine(slowInput());
return;
}
if (input_ControlMapping.Actionmap1.Cancel.ReadValue<float>() != 0)
{
UIconfig.CanvasOnOff_Array[02] = 1;
UIconfig.CanvasOnOff_Array[10] = 0;
numinputtrigger++;
StartCoroutine(slowInput());
return;
}
return;
}
}
//Toolmode
if (UIconfig.CanvasOnOff_Array[10] == 1 && UIconfig.CanvasOnOff_Array[20] == 0 && UIconfig.CanvasOnOff_Array[14] == 1)
{
if (UIconfig.InputManagerVersion == 1)
if (Input.GetButtonDown(toolMode_keyBind))
{
UIconfig.CanvasOnOff_Array[14] = 0;
UIconfig.CanvasOnOff_Array[20] = 1;
return;
}
if (Input.GetButtonDown(MathMode_keyBind))
{
UIconfig.CanvasOnOff_Array[14] = 0;
UIconfig.CanvasOnOff_Array[16] = 1;
return;
}
if (Input.GetButtonDown(cancel_keyBind))
{
UIconfig.CanvasOnOff_Array[02] = 1;
UIconfig.CanvasOnOff_Array[10] = 0;
return;
}
return;
}
Stefan Richter
committed
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
if (UIconfig.InputManagerVersion == 2 && numinputtrigger == 0)
{
if (input_ControlMapping.Actionmap1.ToolMode.ReadValue<float>() != 0)
{
UIconfig.CanvasOnOff_Array[14] = 0;
UIconfig.CanvasOnOff_Array[20] = 1;
numinputtrigger++;
StartCoroutine(slowInput());
return;
}
if (input_ControlMapping.Actionmap1.MathMode.ReadValue<float>() != 0)
{
UIconfig.CanvasOnOff_Array[14] = 0;
UIconfig.CanvasOnOff_Array[16] = 1;
numinputtrigger++;
StartCoroutine(slowInput());
return;
}
if (input_ControlMapping.Actionmap1.Cancel.ReadValue<float>() != 0)
{
UIconfig.CanvasOnOff_Array[02] = 1;
UIconfig.CanvasOnOff_Array[10] = 0;
numinputtrigger++;
StartCoroutine(slowInput());
return;
}
return;
}
}
//PauseMenue
//MathMenue
if (UIconfig.InputManagerVersion == 1)
{
Stefan Richter
committed
if (Input.GetButtonDown(MathMode_keyBind))
{
Stefan Richter
committed
UIconfig.CanvasOnOff_Array[16] = 0;
UIconfig.CanvasOnOff_Array[20] = 1;
return;
}
if (Input.GetButtonDown(cancel_keyBind))
{
Stefan Richter
committed
UIconfig.CanvasOnOff_Array[02] = 1;
UIconfig.CanvasOnOff_Array[10] = 0;
return;
}
return;
}
Stefan Richter
committed
if (UIconfig.InputManagerVersion == 2 && numinputtrigger == 0)
{
if (input_ControlMapping.Actionmap1.MathMode.ReadValue<float>() != 0)
{
UIconfig.CanvasOnOff_Array[16] = 0;
UIconfig.CanvasOnOff_Array[20] = 1;
numinputtrigger++;
StartCoroutine(slowInput());
return;
}
Stefan Richter
committed
if (input_ControlMapping.Actionmap1.Cancel.ReadValue<float>() != 0)
{
UIconfig.CanvasOnOff_Array[02] = 1;
UIconfig.CanvasOnOff_Array[10] = 0;
numinputtrigger++;
StartCoroutine(slowInput());
return;
}
return;
Stefan Richter
committed
}
}
void CheckUI_Vis()
{
//Toolmode
if (UIconfig.CanvasOnOff_Array[14] == 1 && UIconfig.CanvasOnOff_Array[10] == 1)
{
if (LockOnly)
{
CamControl_StdAsset.enabled = !CamControl_StdAsset.enabled;
SetCursorRenderer123(CamControl_StdAsset.enabled);
SetCamControl123(CamControl_StdAsset.enabled);
}
else
{
Cursor.visible = true;
SetCursorRenderer123(true);
Stefan Richter
committed
//SetCamControl123(false);
SetCamControl123(true);
GadgetCanBeUsed = true;
UICanvas.enabled = false;
}
return;
}
//Walkingmode
if (UIconfig.CanvasOnOff_Array[20] == 1 && UIconfig.CanvasOnOff_Array[10] == 1)
{
if (LockOnly)
{
CamControl_StdAsset.enabled = !CamControl_StdAsset.enabled;
SetCursorRenderer123(CamControl_StdAsset.enabled);
SetCamControl123(CamControl_StdAsset.enabled);
}
else
{
Cursor.visible = false;
SetCursorRenderer123(false);
SetCamControl123(true);
Stefan Richter
committed
GadgetCanBeUsed = false;
UICanvas.enabled = false;
}
return;
}
//Mathmode
if (UIconfig.CanvasOnOff_Array[16] == 1 && UIconfig.CanvasOnOff_Array[10] == 1)
{
if (LockOnly)
{
CamControl_StdAsset.enabled = !CamControl_StdAsset.enabled;
SetCursorRenderer123(CamControl_StdAsset.enabled);
SetCamControl123(CamControl_StdAsset.enabled);
}
else
{
Cursor.visible = true;
SetCursorRenderer123(false);
SetCamControl123(false);
UICanvas.enabled = true;
Stefan Richter
committed
GadgetCanBeUsed = false;
}
return;
}
//PauseMenue
if (UIconfig.CanvasOnOff_Array[2] == 1)
{
if (LockOnly)
{
CamControl_StdAsset.enabled = !CamControl_StdAsset.enabled;
SetCursorRenderer123(CamControl_StdAsset.enabled);
SetCamControl123(CamControl_StdAsset.enabled);
}
else
{
Cursor.visible = true;
SetCursorRenderer123(false);
SetCamControl123(false);
UICanvas.enabled = false;
Stefan Richter
committed
GadgetCanBeUsed = false;
}
return;
}
//Startmenue
if (UIconfig.CanvasOnOff_Array[3] == 1)
{
if (LockOnly)
{
CamControl_StdAsset.enabled = !CamControl_StdAsset.enabled;
SetCursorRenderer123(CamControl_StdAsset.enabled);
SetCamControl123(CamControl_StdAsset.enabled);
}
else
{
UICanvas.enabled = false;
Cursor.visible = true;
SetCursorRenderer123(false);
SetCamControl123(false);
Stefan Richter
committed
GadgetCanBeUsed = false;
}
return;
}
if (UIconfig.CanvasOnOff_Array[20] != 1 && UIconfig.CanvasOnOff_Array[14] != 1 && UIconfig.CanvasOnOff_Array[16] != 1)
{
Stefan Richter
committed
//print("CheckHideUI_mobile");
if (LockOnly)
{
CamControl_StdAsset.enabled = !CamControl_StdAsset.enabled;
SetCursorRenderer123(CamControl_StdAsset.enabled);
SetCamControl123(CamControl_StdAsset.enabled);
}
else
{
UICanvas.enabled = false;
CursorRenderer.enabled = false;
Cursor.visible = true;
SetCamControl123(false);
SetCursorRenderer123(false);
UICanvas.enabled = !UICanvas.enabled;
}
return;
}
}
void Update2()
{
if (UIconfig.InputManagerVersion == 1)
if (Input.GetButton(modifier))
if (Input.GetButtonDown(modundo))
StageStatic.stage.factState.undo();
else if (Input.GetButtonDown(modredo))
StageStatic.stage.factState.redo();
else if (Input.GetButtonDown(modreset))
StageStatic.stage.factState.softreset();
else if (Input.GetButtonDown(modsave))
StageStatic.stage.push_record();
else if (Input.GetButtonDown(modload))
{
StageStatic.stage.factState.hardreset();
StageStatic.LoadInitStage(StageStatic.stage.name, !StageStatic.stage.use_install_folder);
}
}
}
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
if (UIconfig.InputManagerVersion == 2)
{
if (input_ControlMapping.Actionmap1.Modifier.ReadValue<float>() != 0)
{
if (input_ControlMapping.Actionmap1.Undo.ReadValue<float>() != 0 && numinputtrigger == 0)
{
StageStatic.stage.factState.undo();
numinputtrigger++;
StartCoroutine(slowInput());
}
else if (input_ControlMapping.Actionmap1.Redo.ReadValue<float>() != 0 && numinputtrigger == 0)
{
StageStatic.stage.factState.redo();
numinputtrigger++;
StartCoroutine(slowInput());
}
else if (input_ControlMapping.Actionmap1.Reset.ReadValue<float>() != 0 && numinputtrigger == 0)
{
StageStatic.stage.factState.softreset();
numinputtrigger++;
StartCoroutine(slowInput());
}
else if (input_ControlMapping.Actionmap1.Save.ReadValue<float>() != 0 && numinputtrigger < 10)
{
StageStatic.stage.push_record();
numinputtrigger= numinputtrigger+10;
StartCoroutine(slowInput());
}
else if (input_ControlMapping.Actionmap1.Load.ReadValue<float>() != 0 && numinputtrigger == 0)
{
StageStatic.stage.factState.hardreset();
StageStatic.LoadInitStage(StageStatic.stage.name, !StageStatic.stage.use_install_folder);
numinputtrigger++;
StartCoroutine(slowInput());
}
}
}
/*
//Todo before capturing: Make directories "UFrameIT-Screenshots/Unity_ScreenCapture" in project folder
else if (Input.GetKeyDown(ScreenshotKey)) {
ScreenCapture.CaptureScreenshot("UFrameIT-Screenshots\\Unity_ScreenCapture\\Capture.png");
}
*/
}
private void SetCursorRenderer123(bool opt)
{
CursorRenderer.enabled = opt;
}
private void SetCamControl123(bool opt)
{
CamControl_StdAsset.enabled = opt;
CamControl_ScriptChar.enabled = opt;
}