Log in or register to post comments

Switch between handheld (mono) mode & stereoscopy AR - help

March 27, 2016 - 7:54am #1
Hi all,
 
I'm using Vuforia 5.5 and runs AR/VR sample on my phone, it starts in a stereoscopy AR mode, and change to stereoscopy VR mode if I gazes the "VR" on the model.
 
Now I want to set a button to switch between handheld mono AR (classic AR) mode and stereoscopy AR mode, I don't know much about code, I hope that someone can help me. 
 
Something like this?
void Start() {
    mCurrentMode = GetMixedRealityMode();
    Button btn = this.GetComponent<Button>();
    btn.onClick.AddListener(Onclick);
}
  
private void Onclick(){
    if (mCurrentMode == MixedRealityController.Mode.VIEWER_AR) {
        MixedRealityController.Instance.SetMode(MixedRealityController.Mode.HANDHELD_AR);
    } else {
        MixedRealityController.Instance.SetMode(MixedRealityController.Mode.VIEWER_AR);
    }
}

 

 
Thanks in advance!

Switch between handheld (mono) mode & stereoscopy AR - help

April 7, 2016 - 8:15am #2

I just found a way to do this:

 

	void OnGUI () {
		if(GUILayout.Button("mono?")){
			if (mono) {
				mono = false;
				GameObject.Find ("StereoDivisionCanvas").GetComponent<Canvas> ().enabled=true;
				GameObject.Find ("Reticle").GetComponent<MeshRenderer> ().enabled=true;
			} else {
				mono = true;
				GameObject.Find ("StereoDivisionCanvas").GetComponent<Canvas> ().enabled=false;
				GameObject.Find ("Reticle").GetComponent<MeshRenderer> ().enabled=false;
			}
		};
	}

 

and edit:

        if (InAR)
        {
			return mono ?
                MixedRealityController.Mode.HANDHELD_AR : MixedRealityController.Mode.VIEWER_AR;
        }
        else // in VR
        {
			return mono ?
                MixedRealityController.Mode.HANDHELD_VR : MixedRealityController.Mode.VIEWER_VR;
        }

 

but I think it's not a regular way to do this.

Log in or register to post comments