Reputation: 215
I am using vuforia library in my unity project where I need to change the DigitalEyewearBehaviour properties on a users button click action. So far the orientation of the screen changes and when checked through the debug log the eyewear type and the mode both are seem to be set perfectly. But the device only changes the screen orientation to landscape and blacks out the camera.
public void ChangeToHeadGearMode(){
//static setting changes
Screen.orientation = ScreenOrientation.Landscape;
//Getting Player Settings
string ViewerType = PlayerPrefs.GetString("Viewer Type","Generic Cardboard (Vuforia)");
string SterioFrameWork = PlayerPrefs.GetString ("Sterio Framework", "0");
mDebug.Log ("Getting VT " + ViewerType);
mDebug.Log ("Getting SF " + SterioFrameWork);
//setting set
mDebug.Log (mHeadGearParameters.GetEyewearType().ToString());
mHeadGearParameters.SetEyewearType(Vuforia.DigitalEyewearAbstractBehaviour.EyewearType.VideoSeeThrough);
mDebug.Log (mHeadGearParameters.GetEyewearType().ToString());
if(SterioFrameWork=="0")
{
mHeadGearParameters.SetStereoCameraConfiguration(Vuforia.DigitalEyewearAbstractBehaviour.StereoFramework.Vuforia);
mDebug.Log ("ST=0");
}
else if(SterioFrameWork=="1")
{
mHeadGearParameters.SetStereoCameraConfiguration(Vuforia.DigitalEyewearAbstractBehaviour.StereoFramework.Cardboard);
mDebug.Log ("ST=1");
}
else if(SterioFrameWork=="2")
{
mHeadGearParameters.SetStereoCameraConfiguration(Vuforia.DigitalEyewearAbstractBehaviour.StereoFramework.GearVR);
mDebug.Log ("ST=2");
}
mHeadGearParameters.SetViewerActive (true,true);
}
The vuforia developer portal says a method as SetViewerActive
When I apply that method only the camera blacks out. If I does not use that the camera does not black out but the view does not change to cardboard view. I have tried all the possible options in SetViewerActive
method but does not work. I went through the vuforia developer portal a number of times but did not find the error.
What am I doing wrong or where am I missing an important point?
Upvotes: 2
Views: 1003
Reputation: 21
Remember to active again the normal view: use DigitalEyewearARController.Instance.SetViewerActive(false, true);
to deactivate it and reset the camera.
Upvotes: 1
Reputation: 215
I found the answer to my own question and I am posting it to anyone who might come across the same problem. As of now there are no tutorials or real examples of how this actually works. So I had to go with trial and error and finally I found the solution.
The thing you need to do is just deinit the camera instance and then do the setting changes and then SetViewerActive(true,true)
so that the camera will be reinitialised.
The final solution is as follows.
//static setting changes
Screen.orientation = ScreenOrientation.Landscape;
if (CameraDevice.Instance.Stop () && CameraDevice.Instance.Deinit ())
{
//Getting Player Settings
string ViewerType = PlayerPrefs.GetString("Viewer Type","Generic Cardboard (Vuforia)");
string SterioFrameWork = PlayerPrefs.GetString ("Sterio Framework", "0");
mDebug.Log ("Getting VT " + ViewerType);
mDebug.Log ("Getting SF " + SterioFrameWork);
//setting set
mDebug.Log (mHeadGearParameters.GetEyewearType().ToString());
mHeadGearParameters.SetEyewearType(DigitalEyewearAbstractBehaviour.EyewearType.VideoSeeThrough);
mDebug.Log (mHeadGearParameters.GetEyewearType().ToString());
if(SterioFrameWork=="0")
{
mHeadGearParameters.SetStereoCameraConfiguration(DigitalEyewearAbstractBehaviour.StereoFramework.Vuforia);
mDebug.Log ("ST=0");
}
else if(SterioFrameWork=="1")
{
mHeadGearParameters.SetStereoCameraConfiguration(DigitalEyewearAbstractBehaviour.StereoFramework.Cardboard);
mDebug.Log ("ST=1");
}
else if(SterioFrameWork=="2")
{
mHeadGearParameters.SetStereoCameraConfiguration(DigitalEyewearAbstractBehaviour.StereoFramework.GearVR);
mDebug.Log ("ST=2");
}
mHeadGearParameters.SetViewerActive (true,true);
}
Upvotes: 1