-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenuUI.cs
More file actions
89 lines (77 loc) · 2.82 KB
/
Copy pathMainMenuUI.cs
File metadata and controls
89 lines (77 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System.Collections;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.Interaction.Toolkit.Locomotion.Teleportation;
public class MainMenuUI : MonoBehaviour
{
//
public GameObject IsThisKeyboardPortMode;
//
// Init:
public MainPlrScript mainPlrScript;
public TeleportationProvider teleportProvider;
//
public Button playButton;
public Button exitGameButton;
public Button playButton_PCPort;
public Button exitGameButton_PCPort;
//
public GameObject spawnObj;
public GameObject InGameUI;
public GameObject lanternObj;
public GameObject swordObj;
//
public void ManualSafeTeleport(Vector3 targetPos) {
mainPlrScript.TogglePlayerMovement(false);
if (IsThisKeyboardPortMode.activeSelf == true)
{
IsThisKeyboardPortMode.transform.position = targetPos;
Physics.SyncTransforms();
mainPlrScript.TogglePlayerMovement(true);
return;
}
// Create a request that the Mediator can understand
var request = new TeleportRequest
{
destinationPosition = targetPos,
matchOrientation = MatchOrientation.WorldSpaceUp // Keeps player upright
};
// Queues the teleport safely through the XRI 3.0 system
teleportProvider.QueueTeleportRequest(request);
//
mainPlrScript.TogglePlayerMovement(true);
}
//--------//
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
if (IsThisKeyboardPortMode.activeSelf == true)
{
InGameUI = IsThisKeyboardPortMode.transform.GetChild(0).GetChild(0).GetChild(0).gameObject;
mainPlrScript = IsThisKeyboardPortMode.GetComponent<MainPlrScript>();
lanternObj = IsThisKeyboardPortMode.transform.GetChild(0).GetChild(1).GetChild(0).gameObject;
swordObj = IsThisKeyboardPortMode.transform.GetChild(0).GetChild(2).GetChild(0).gameObject;
//
playButton_PCPort.onClick.AddListener(StartGameFunc);
exitGameButton_PCPort.onClick.AddListener(QuitGameFunc);
return;
}
playButton.onClick.AddListener(StartGameFunc);
exitGameButton.onClick.AddListener(QuitGameFunc);
}
public void StartGameFunc()
{
ManualSafeTeleport(spawnObj.transform.position);
mainPlrScript.TogglePlayerMovement(true);
//print("teleported player to main world!");
InGameUI.SetActive(true);
lanternObj.SetActive(true);
swordObj.SetActive(true);
}
public void QuitGameFunc()
{
print("Quit game!");
Application.Quit();
}
}