Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions POINT-VR-Chapter-1/Assets/POINT/InputAssets/SceneController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using System.Collections.Generic;

/// <summary>
/// Stores integer values under scene names. Do not change these intergers (you should be changing the SceneDict dictionary below). Integers are linked to build settings scene integers in the dictionary SceneDict (defined in SceneController).
/// There are two layers of this (enum here, and the dict down below) because the Unity Editor stores the value of the enum, not its name. So if the build settings change and you change the enum in the code then what the editor stores
/// won't actually change.
/// </summary>
public enum SceneNumEnum
{
StartMenu = 114,
Tutorial = 97,
Ch1_Scene1 = 115,
Conf_Demo_P1 = 116,
Conf_Demo_P2 = 108,
Conf_Demo_P3 = 101,
EndCredits = 121
}

/// <summary>
/// This script should be on the player prefab. It communicates the player's setting to the GameManager before switching scenes and then retrieves this information upon being instantiated.
/// </summary>
Expand Down Expand Up @@ -50,6 +68,21 @@ public class SceneController : MonoBehaviour
/// <summary>
/// When Instantiated: Get the player data. Communicate this data to all component arguments.
/// </summary>

/// <summary>
/// Relates the shown enum (left) to scene numbers in build settings. If the scene numbers in build settings change you should update
/// the right side of the dictionary (the values) with the new numbers.
/// </summary>
private Dictionary<int, int> SceneDict = new Dictionary<int, int>
{
{ (int) SceneNumEnum.StartMenu, 0 },
{ (int) SceneNumEnum.Tutorial, 1 },
{ (int) SceneNumEnum.Ch1_Scene1, 2 },
{ (int) SceneNumEnum.Conf_Demo_P1, 3 },
{ (int) SceneNumEnum.Conf_Demo_P2, 4 },
{ (int) SceneNumEnum.Conf_Demo_P3, 5 },
{ (int) SceneNumEnum.EndCredits, 6 }
};
private void Start()
{
GameManager.PlayerData data = GameManager.Instance.GetData();
Expand All @@ -58,7 +91,7 @@ private void Start()
functional.value = data.functionalVolume;
aesthetic.value = data.aestheticVolume;
uiManager.Language = (int)data.language;
uiManager.SubtitleLanguage = (int) data.subtitleLanguage;
uiManager.SubtitleLanguage = (int)data.subtitleLanguage;
music.mute = false;
floorToggle.IsOn = data.isFloorVisible;
hapticToggle.IsOn = data.isHapticsEnabled;
Expand All @@ -81,10 +114,16 @@ public void ChangeScene(int scene)
isHapticsEnabled = hapticToggle.IsOn,
isControllerHighlighted = highlightsToggle.IsOn,
language = (GameManager.Language)uiManager.Language,
subtitleLanguage = (GameManager.Language) uiManager.SubtitleLanguage
subtitleLanguage = (GameManager.Language)uiManager.SubtitleLanguage
};
GameManager.Instance.SetData(data);
pause.Unpause();
SceneManager.LoadScene(scene);
}
}

// Using a function here so the dictionary can't be modified and we don't have to bother passing larger object (I lack C# knowledge; there may be a better way to do this)
public int OperateSceneDict(int SceneNumEnum_number)
{
return SceneDict[SceneNumEnum_number];
}
}
10 changes: 8 additions & 2 deletions POINT-VR-Chapter-1/Assets/POINT/InputAssets/StartMenuManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
Expand All @@ -24,6 +25,11 @@ public class StartMenuManager : MonoBehaviour
[Tooltip("Default localized string that appears under current objective in the UI menu")]
[SerializeField] private LocalizedString defaultObjective;

[SerializeField] SceneNumEnum Tutorial_Enum;

[SerializeField] SceneNumEnum End_Credits_Enum;


/// <summary>
/// A reference to the player GameObject
/// </summary>
Expand Down Expand Up @@ -242,7 +248,7 @@ public void StartGame()
SceneController sceneController = player.GetComponentInChildren<SceneController>();
if (sceneController != null)
{
sceneController.ChangeScene(1);
sceneController.ChangeScene(sceneController.OperateSceneDict((int) Tutorial_Enum));
}
}
}
Expand Down Expand Up @@ -271,7 +277,7 @@ public void StartCredits()
SceneController sceneController = player.GetComponentInChildren<SceneController>();
if (sceneController != null)
{
sceneController.ChangeScene(6);
sceneController.ChangeScene(sceneController.OperateSceneDict((int) End_Credits_Enum));
}
}
}
Expand Down