Files
RoomAwareVR/Assets/_Scripts/Utility/FlushAndLoad.cs
T
2025-07-01 00:20:56 +02:00

61 lines
1.4 KiB
C#

using GhostSystem;
using UnityEngine;
using UnityEngine.SceneManagement;
using TMPro;
using System.Collections.Generic;
public class FlushAndLoad : MonoBehaviour
{
public TMP_Text output;
public GhostRecorderBatch recorder;
public GameObject loadingScreen;
public GameObject canvas;
private void OnEnable()
{
GhostRecorderBatch.OnUploadFinished += HandleUploadFinished;
RoomManager.OnSceneIdReady += HandleSceneIdReady;
}
private void OnDisable()
{
GhostRecorderBatch.OnUploadFinished -= HandleUploadFinished;
RoomManager.OnSceneIdReady -= HandleSceneIdReady;
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
if (OVRInput.GetDown(OVRInput.Button.SecondaryIndexTrigger))
{
output.text = "Flush...";
loadingScreen.SetActive(true);
canvas.SetActive(false);
recorder.Flush();
GetComponent<SceneLoader>().NewRoom();
}
}
private void HandleUploadFinished()
{
loadingScreen.SetActive(false);
output.text = "";
}
private void HandleSceneIdReady(string id, List<GameObject> doors)
{
if (id == "Room1")
{
loadingScreen.SetActive(false);
}
}
}