Log in or register to post comments

Changing from none to Cardboard on UI button click

December 1, 2016 - 11:03pm #1

Hello



I would like to change from digital eyewear none to digital eyewear google card board in unity app throw code.

I'm making a sample application just to show how AR is working and I would like to have a button in the UI to change from using only the phone. And then by pressing a button in the app i would like to change to stereo vision and put the phone in a cardboard vr headset.



Everything is working but i don't know how to change the settings in the button event, if i change it manually in unity and run the app it works.

public class ChangeEyeWear : MonoBehaviour {

    private static bool vr = false;

    // Use this for initialization

    void Start () {

        Button b = gameObject.GetComponent<Button>();

        b.onClick.AddListener(TaskOnClick);

    }



// Update is called once per frame

void Update () {



}

    void TaskOnClick()

    {

        if (!vr) {

            Vuforia.DigitalEyewearBehaviour.Instance.SetMode(Device.Mode.MODE_AR);

            Vuforia.DigitalEyewearBehaviour.Instance.SetStereoCameraConfiguration(DigitalEyewearAbstractBehaviour.StereoFramework.Cardboard);

            Vuforia.DigitalEyewearBehaviour.Instance.SetEyewearType(DigitalEyewearAbstractBehaviour.EyewearType.OpticalSeeThrough);

            vr = true;

        }

        else

        {

            Vuforia.DigitalEyewearBehaviour.Instance.SetMode(Device.Mode.MODE_AR);

            Vuforia.DigitalEyewearBehaviour.Instance.SetStereoCameraConfiguration(DigitalEyewearAbstractBehaviour.StereoFramework.Cardboard);

            Vuforia.DigitalEyewearBehaviour.Instance.SetEyewearType(DigitalEyewearAbstractBehaviour.EyewearType.None);

            vr = false;

        }

        

    }

}

Log in or register to post comments