Cleaned up and commented version.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
// Ehemaliges Skript für die Start-Szene. Nicht mehr in Verwendung
|
||||
|
||||
public class GameStarter : MonoBehaviour
|
||||
{
|
||||
[SerializeField] int startScene = 1;
|
||||
private int currentscene;
|
||||
private int nextscene;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
StopRecordingTrigger.OnRecordStop += HandleRecordStop;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
StopRecordingTrigger.OnRecordStop -= HandleRecordStop;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
DontDestroyOnLoad(this);
|
||||
currentscene = startScene;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (OVRInput.GetDown(OVRInput.Button.SecondaryIndexTrigger))
|
||||
{
|
||||
if (SceneManager.GetActiveScene() != SceneManager.GetSceneByBuildIndex(startScene)) return;
|
||||
nextscene = currentscene + 1;
|
||||
currentscene = nextscene;
|
||||
StartGameByLoadingScene(nextscene);
|
||||
}
|
||||
}
|
||||
|
||||
void StartGameByLoadingScene(int sceneIndex)
|
||||
{
|
||||
SceneManager.LoadScene(sceneIndex);
|
||||
}
|
||||
|
||||
private void HandleRecordStop()
|
||||
{
|
||||
StartGameByLoadingScene(startScene);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user