Cleaned Scripts, added comments, added end scene
This commit is contained in:
@@ -3,14 +3,18 @@ using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using TMPro;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FlushAndLoad : MonoBehaviour
|
||||
{
|
||||
public TMP_Text output;
|
||||
public TMP_Text instruction;
|
||||
public GhostRecorderBatch recorder;
|
||||
public GameObject loadingScreen;
|
||||
public GameObject canvas;
|
||||
|
||||
private string sceneId;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
GhostRecorderBatch.OnUploadFinished += HandleUploadFinished;
|
||||
@@ -34,13 +38,17 @@ public class FlushAndLoad : MonoBehaviour
|
||||
{
|
||||
if (OVRInput.GetDown(OVRInput.Button.SecondaryIndexTrigger))
|
||||
{
|
||||
output.text = "Flush...";
|
||||
loadingScreen.SetActive(true);
|
||||
canvas.SetActive(false);
|
||||
|
||||
recorder.Flush();
|
||||
GetComponent<SceneLoader>().NewRoom();
|
||||
if (sceneId == "End") Application.Quit();
|
||||
else
|
||||
{
|
||||
output.text = "Flush...";
|
||||
loadingScreen.SetActive(true);
|
||||
canvas.SetActive(false);
|
||||
|
||||
recorder.Flush();
|
||||
GetComponent<SceneLoader>().NewRoom();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,10 +56,18 @@ public class FlushAndLoad : MonoBehaviour
|
||||
{
|
||||
loadingScreen.SetActive(false);
|
||||
output.text = "";
|
||||
|
||||
if (sceneId == "End")
|
||||
{
|
||||
output.text = "Durchlauf beendet.";
|
||||
instruction.text = "Drücke den rechten Trigger, um die Anwendung zu beenden.";
|
||||
canvas.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleSceneIdReady(string id, List<GameObject> doors)
|
||||
{
|
||||
sceneId = id;
|
||||
if (id == "Room1")
|
||||
{
|
||||
loadingScreen.SetActive(false);
|
||||
|
||||
@@ -52,7 +52,7 @@ public class SceneLoader : MonoBehaviour
|
||||
LoadNewRoom();
|
||||
}
|
||||
|
||||
private async UniTaskVoid LoadNewRoom()
|
||||
private async UniTaskVoid LoadNewRoom() // Aktuelle Methode zum Laden von Szenen
|
||||
{
|
||||
int sceneCount = SceneManager.sceneCount;
|
||||
|
||||
@@ -65,7 +65,15 @@ public class SceneLoader : MonoBehaviour
|
||||
await SceneManager.UnloadSceneAsync(myScene);
|
||||
}
|
||||
}
|
||||
await SceneManager.LoadSceneAsync(currentScene + 1, LoadSceneMode.Additive);
|
||||
Debug.Log("Loaded Room " + currentScene + 1);
|
||||
if (currentScene == SceneManager.sceneCountInBuildSettings-1)
|
||||
{
|
||||
await SceneManager.LoadSceneAsync(baseSceneIndex); // Lädt die Basis-Szene komplett neu, falls vorherige Szene die letzte war.
|
||||
}
|
||||
else
|
||||
{
|
||||
await SceneManager.LoadSceneAsync(currentScene + 1, LoadSceneMode.Additive); // Lädt die nächste Szene additiv
|
||||
Debug.Log("Loaded Room " + (currentScene + 1));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user