unity-game-enginevirtual-realitygoogle-cardboard

GvrEventSystem vs EventSystem


Working on a Unity hybrid VR (cardboard) /2D app. The cardboard side of it works fine. I am having trouble with the 2D/VR switching.

When I am in 2D mode, reticle does not move, although screen taps register. So the app seems unaware of the gyro.

I feel like I am missing something fundamental here. I have a GvrEventSystem prefab that has both an EventSystem and GvrPointerInputModule components.

What obvious thing am I over-looking?

ETA:

I have been asked to add relevant code. Here is the code for 2D-VR switching on-the-fly. This code executes w/out error, and the app switches between VR and 2D mode every 3 seconds:

  readonly string NONE_STRING = "";
  readonly string CARDBOARD_STRING = "cardboard";

  void Start()
  {
    Invoke("GoPhone", 3.0f);
  }

  void GoPhone()
  {
    SetVREnabled(false);
    Invoke("GoVR", 3.0f);
  }

  void GoVR()
  {
    SetVREnabled(true);
    Invoke("GoPhone", 3.0f);
  }

  void SetVREnabled(bool isEnabled)
  {
    if (isEnabled)
    {
      StartCoroutine(LoadDevice(CARDBOARD_STRING));
    }
    else
    {
      StartCoroutine(LoadDevice(NONE_STRING));
    }
  }

  IEnumerator LoadDevice(string newDevice)
  {
    if (String.Compare(XRSettings.loadedDeviceName, newDevice, true) != 0)
    {
      XRSettings.LoadDeviceByName(newDevice);

      yield return null;

      if (!XRSettings.loadedDeviceName.Equals(NONE_STRING))
        XRSettings.enabled = true;
    }
  }

Although I feel like my problem is a configuration problem, and not a code problem. In the editor, which does not support VR mode, the app behaves in 2D mode as expected.

Also ETA:

GVREventSystem Camera

JIC


Solution

  • User error! I did not follow the "Magic Window" instructions as detailed at https://developers.google.com/vr/develop/unity/guides/magic-window... let my folly be a warning to future generations!