-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHandleMenu.cs
81 lines (61 loc) · 3.12 KB
/
HandleMenu.cs
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
using System.Collections;
using Normal.Realtime;
using UnityEngine.UI;
using MelonLoader;
using UnityEngine;
using System;
using TMPro;
namespace BricksVR
{
public class HandleMenu
{
public static void HandleButtons(SingleBrick instance)
{
GameObject playButton = instance.playButton;
GameObject joinButton = instance.joinButton;
GameObject settingsButton = instance.settingsButton;
GameObject.DestroyImmediate(playButton.GetComponent<Button>());
playButton.AddComponent<Button>();
Button playButtonComponent = playButton.GetComponent<Button>();
joinButton.SetActive(false);
Vector3 templatePosition = settingsButton.transform.localPosition;
playButton.transform.localPosition = new Vector3(templatePosition.x, playButton.transform.localPosition.y, templatePosition.z);
playButton.transform.localScale = settingsButton.transform.localScale;
TextMeshProUGUI text = playButton.GetComponentInChildren<TextMeshProUGUI>();
text.text = "Play";
Action action = () =>
MelonCoroutines.Start(HandlePlay());
playButtonComponent.onClick.AddListener(action);
}
public static IEnumerator HandlePlay()
{
NormalSessionManager sessionManager = GameObject.Find("MetaObjects/NormalSessionManager").GetComponent<NormalSessionManager>();
if (sessionManager != null)
{
sessionManager._brickStore.ClearAndRemoveFromWorld();
sessionManager.WarmOtherCaches();
BrickPrefabCache.GetInstance().GenerateCache();
sessionManager.brickPickerMenu.WarmMenu();
BrickColorMap.WarmColorDictionary();
sessionManager.buttonInput.DisableMenuControls();
GameObject customModel = GameObject.Instantiate(Resources.Load<GameObject>("Custom VR Player"));
customModel.AddComponent<Scripts.Avatar>();
GameObject.Destroy(customModel.GetComponent<RealtimeTransform>());
GameObject.Destroy(customModel.GetComponent<RealtimeAvatar>());
GameObject.Destroy(customModel.GetComponent<RealtimeView>());
AvatarNicknameSync avatarSync = customModel.GetComponent<AvatarNicknameSync>();
avatarSync._isSelf = true;
avatarSync.nameText.enabled = false;
avatarSync.face.SetActive(false);
sessionManager.mainEnvironment.SetActive(true);
sessionManager.menuEnvironment.SetActive(false);
sessionManager.playerControllers.transform.position = sessionManager.gameSpawnPoint.position;
sessionManager.playerControllers.transform.rotation = sessionManager.gameSpawnPoint.rotation;
sessionManager.menuBoard.SetActive(false);
yield return new WaitForSeconds(0.25f);
sessionManager.joystickLocomotion.enabled = true;
sessionManager._didConnectToRoom = true;
}
}
}
}