AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
SceneSwitcher.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using System.Collections;
5 using System.Collections.Generic;
6 using UnityEngine;
7 using UnityEngine.SceneManagement;
8 
9 namespace HoloToolkit.Examples.Prototyping
10 {
14  public class SceneSwitcher : MonoBehaviour
15  {
19  public void NextScene()
20  {
21  int sceneCount = SceneManager.sceneCountInBuildSettings;
22 
23  for (int i = 0; i < sceneCount; ++i)
24  {
25  if (i < sceneCount - 1)
26  {
27  if (SceneManager.GetActiveScene() == SceneManager.GetSceneByBuildIndex(i))
28  {
29  SceneManager.LoadScene(i + 1);
30  break;
31  }
32  }
33  else
34  {
35  SceneManager.LoadScene(0);
36  }
37  }
38  }
39 
43  public void PreviousScene()
44  {
45  int sceneCount = SceneManager.sceneCount;
46 
47  for (int i = 0; i < sceneCount; ++i)
48  {
49  if (i > 1)
50  {
51  if (SceneManager.GetActiveScene() == SceneManager.GetSceneAt(i))
52  {
53  SceneManager.LoadScene(i - 1);
54  break;
55  }
56  }
57  else
58  {
59  SceneManager.LoadScene(sceneCount - 1);
60  }
61  }
62  }
63  }
64 }
void NextScene()
Load the next scene, if at the end of the list, load the first scene
void PreviousScene()
Load the previous scene, if at the beginning of the list, load the first scene
Switches scenes, next scene or previous scene