-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenterSceneManager.cs
More file actions
57 lines (46 loc) · 1.45 KB
/
enterSceneManager.cs
File metadata and controls
57 lines (46 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Google.XR.Cardboard;
using UnityEngine.XR;
using UnityEngine.XR.Management;
public class enterSceneManager : MonoBehaviour
{
private Camera _mainCamera;
// Field of view value to be used when the scene is not in VR mode. In case
// XR isn't initialized on startup, this value could be taken from the main
// camera and stored.
private const float _defaultFieldOfView = 60.0f;
private void Awake(){
_mainCamera = Camera.main;
}
private void Start(){
ExitVR();
}
public void LoadVRScene(){
SceneManager.LoadScene(1);
}
/// <summary>
/// Exits VR mode.
/// </summary>
private void ExitVR()
{
StopXR();
}
/// <summary>
/// Stops and deinitializes the Cardboard XR plugin.
/// See https://docs.unity3d.com/Packages/com.unity.xr.management@3.2/manual/index.html.
/// </summary>
private void StopXR()
{
Debug.Log("Stopping XR...");
XRGeneralSettings.Instance.Manager.StopSubsystems();
Debug.Log("XR stopped.");
Debug.Log("Deinitializing XR...");
XRGeneralSettings.Instance.Manager.DeinitializeLoader();
Debug.Log("XR deinitialized.");
_mainCamera.ResetAspect();
_mainCamera.fieldOfView = _defaultFieldOfView;
}
}