I’m a newbie in Unity so please be patient with me ![]()
I’m trying to make a script from the a menu scene(0) that will enable or disable vr mode in the next scene(1) via gui button click. Unfortunately, the button that disables the vr mode isn’t working.
This is the script that I am using in the menu scene(0). It creates an instance of itself in the next scene(1) and enables or disables the vr mode on the next scene(1). Or at least that’s what I’m trying to make it do.
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
public class cameraModeScript : MonoBehaviour {
static cameraModeScript Instance;
void Start(){
//destroy or preserve instance
if (Instance != null) {
GameObject.Destroy (gameObject);
}
else {
GameObject.DontDestroyOnLoad (gameObject);
Instance = this;
}
}
//vr mode button is clicked
public void vrmode()
{
Debug.Log ("VR Mode button clicked!");
Start();
//load next scene
SceneManager.LoadScene(1);
//set cam to vr mode
GvrViewer.Create();
GvrViewer.Instance.VRModeEnabled = true;
Debug.Log ("VR Mode button Enabled!");
}
//normal mode button is clicked
public void normalmode()
{
Debug.Log ("Normal Mode button clicked!");
Start ();
//Load next scene
SceneManager.LoadScene(1);
//set cam to normal mode
GvrViewer.Create();
GvrViewer.Instance.VRModeEnabled = false;
Debug.Log ("Normal Mode Enabled!");
}
}
Setting the GvrViewer.Instance.VRModeEnabled to true in line 28 seems to work but when I set it to false in line 41, it doesn’t seem to work. The camera in the next scene is still being rendered in stereo mode.
The next scene(1) already has the GvrViewerMain object so maybe that’s what’s causing the problem? I really have no idea what to do.
Any kind of help will be much appreciated. Thank You:)