Reputation: 51
In my menu scene, I have a boolean button that triggers the function LoadStereo()
, which allows either VRModeEnabled
or !VRModeEnabled
.
GvrViewer MonoOrStereo = new GvrViewer();
void Awake() {
bool stereo = MonoOrStereo.VRModeEnabled;
}
public void LoadStereo(bool stereo) {
Debug.Log (stereo);
}
This seems to be logging true and false so my two buttons are giving me the right values when clicked.
But I'm having trouble sending this value to the Loaded scene. In the start function of the Loaded scene, I have
void Start() {
GameObject MonoOrStereo = GameObject.Find("MonoOrStereo");
Menu menu = MonoOrStereo.GetComponent<Menu>();
}
but I cant access the boolean menu.stereo
, only menu.LoadStereo()
. How can I turn this into a boolean I can use in my code?
Upvotes: 0
Views: 118
Reputation: 125445
You can't access the stereo
variable from the Menu
script because stereo
is declared in a function. Declare it outside a function then initialize it in the Awake()
function. You must also make it public
in order to be able to access it.
public GvrViewer MonoOrStereo = new GvrViewer();
public bool stereo;
void Awake() {
stereo = MonoOrStereo.VRModeEnabled;
}
public void LoadStereo(bool stereo) {
Debug.Log (stereo);
}
Upvotes: 1