Documentation for the Unity C# Library
Loading...
Searching...
No Matches
SceneLoader.cs
Go to the documentation of this file.
1using PixoVR.Core;
3using UnityEngine;
4using UnityEngine.SceneManagement;
5
6namespace PixoVR.Event
7{
8 public class SceneLoader : MonoBehaviour
9 {
10 const string LOGIN_SCENE = "Login";
11 const string LOBBY_SCENE = "LobbyRoom";
12 const string SCENARIO_SCENE = "Scenario";
13
15
17
18 private void Start()
19 {
21 }
22
23 public void LoadScene(SceneType sceneType)
24 {
26
27 _fadeEffect.Fade(FadeAction.FadeIn, () =>
28 {
29 SceneManager.LoadScene(GetSceneName(sceneType));
30 });
31
32 _currentSceneType = sceneType;
33 }
34
35 public void RestartScene()
36 {
38
39 _fadeEffect.Fade(FadeAction.FadeIn, () =>
40 {
41 SceneManager.LoadScene(GetSceneName(_currentSceneType));
42 });
43 }
44
45 private static string GetSceneName(SceneType sceneType)
46 {
47 return sceneType switch
48 {
49 SceneType.Login => LOGIN_SCENE,
50 SceneType.Lobby => LOBBY_SCENE,
51 SceneType.Scenario => SCENARIO_SCENE,
52 _ => ""
53 };
54 }
55 }
56
57 public enum SceneType
58 {
60 Lobby,
61 Login
62 }
63}
Main camera fade logic.
Definition FadeEffect.cs:13
void Fade(FadeAction fadeAction, Action callback, Action centerCallback=null)
Definition FadeEffect.cs:19
Unity components communication service.
static string GetSceneName(SceneType sceneType)
const string SCENARIO_SCENE
void LoadScene(SceneType sceneType)