Hi
my project has been on hold for the last 5 months. Do i need to be aware of any upgrades to VR implementation for google cardboard, either from Unity or the SDK?
thanks
Highly unlikely. Pretty much nobody (including Google) does Cardboard anymore.
wait i’m working on one… : p
cardboard plugin releases history:
and current recommended unity version 2019.4.25f1.
Well then, I stand corrected.
@mgear thanks for the update. Does this fix the problem of toggling between 2d and VR mode? My app was crashing whenever i did this previously. Also does it include a replacement for GVRreticlepointer? So I can navigate in game in the editor?
thanks for your efforts
most of the help is coming from this topic
https://github.com/googlevr/cardboard/issues/140
for testing in editor,
have to make own script apparently, i’m using this: (left alt down and move mouse to rotate cam)
reticle:
i’m actually still in 1.6, haven’t checked if better reticle got added,
for the timer i used UI 360 slider image with small script that sets the fill amount… (raycast to detect if hover over target)
and for the circular white expanding part, i used old reticle code (the one that builds circular mesh and expands it from shader)
2d/vr mode switch:
i had crashing also, their main example for switching mode doesnt work…
i’m using some messy code like, and app is set to NOT have vr enabled at start (so its disabled from xr settings)
thanks very much for that code - will give it a go… I have avoided upgrading to 2020 and am still on 2019.4.0f1… is that the best version to stick with?
thanks
i’m definitely staying with 2019.4.x on this one,
and in general, avoiding 2020/2021, editor feels too sluggish…
just noticed this is an image - any chance you can share the text version? thanks
can skip the debug logs, so then can copy same parts from here:
https://github.com/googlevr/cardboard/issues/140
Hi I have implemented this code and it works the first time but the app crashes when i try to go back into VR. Any ideas? (I had to comment out the cam.* lines as they gave up errors in my editor)
using System.Collections;
using UnityEngine;
using UnityEngine.XR.Management;
public class VRToggle : MonoBehaviour
{
public bool vrOn;
public void Start()
{
if (vrOn)
{
StartCoroutine(VRStart());
}
else
{
VRStop();
}
}
public IEnumerator VRStart()
{
var xrManager = XRGeneralSettings.Instance.Manager;
if (!xrManager.isInitializationComplete)
{
yield return xrManager.InitializeLoader();
xrManager.StartSubsystems();
Screen.sleepTimeout = SleepTimeout.NeverSleep;
}
}
public void VRStop()
{
var xrManager = XRGeneralSettings.Instance.Manager;
if (xrManager.isInitializationComplete)
{
xrManager.StopSubsystems();
xrManager.DeinitializeLoader();
//cam.ResetAspect();
//cam.fieldOfView = defaultFov;
//cam.ResetProjectionMatrix();
//cam.ResetWorldToCameraMatrix();
Screen.sleepTimeout = SleepTimeout.SystemSetting;
}
}
}
my app has xr disabled at start:
StartXR, not sure if much difference to yours:
private IEnumerator StartXR()
{
Debug.Log("Initializing XR...");
if (!XRGeneralSettings.Instance.Manager.isInitializationComplete) yield return XRGeneralSettings.Instance.Manager.InitializeLoader();
yield return 0;
if (XRGeneralSettings.Instance.Manager.activeLoader == null)
{
Debug.LogError("Initializing XR Failed.");
}
else
{
Debug.Log("Starting XR...");
XRGeneralSettings.Instance.Manager.StartSubsystems();
}
stopXR
Debug.Log("Stopping XR...");
if (XRGeneralSettings.Instance != null) XRGeneralSettings.Instance.Manager.StopSubsystems();
Camera.main.ResetAspect();
yes - that is unchecked at the start since user begins in 2d screens
I swapped my code for your and now see this error when I try going back into VR
Initializing XR Failed.
UnityEngine.Debug:LogError(Object)
d__2:MoveNext() (at Assets/MyStuff/Scripts/VRToggle.cs:33)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
if (XRGeneralSettings.Instance.Manager.activeLoader == null)
{
Debug.LogError("Initializing XR Failed.");
}
(not sure if relevant but I haven’t installed the latest SDK you linked to, primarily because I can’t see a unitypackage file when i download). Do I need that installed? If so how do I do this without the package manager? thanks )
you mean the cardboard sdk? yeah i guess that could affect things,
can install that from package manager, steps:
*ah… not sure whats the non-package manager way…
ok did it that way but still get the same error - presumably this is why it is crashing… any ideas? NB I now can’t enter VR mode when i install the app on phone (android). This is both with your code and mine
any other ideas? thanks
whats the error message in device log?
with your code?
Initializing XR Failed.
UnityEngine.Debug:LogError(Object)
d__2:MoveNext() (at Assets/MyStuff/Scripts/VRToggle.cs:33)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
i have these packages and versions
Hi, it looks like you are using 1.6.0. There are some bug fixes, and improvements in the new 1.8.0 plugin.