Example #1
0
    void Awake()
    {
        if (instance != null)
        {
            Debug.LogError("More than one GvrController instance was found in your scene. "
                           + "Ensure that there is only one GvrController.");
            this.enabled = false;
            return;
        }
        instance = this;
        if (controllerProvider == null)
        {
            controllerProvider = ControllerProviderFactory.CreateControllerProvider(this);
        }

        // Keep screen on here, in case there isn't a GvrViewerMain prefab in the scene.
        // This ensures the behaviour for:
        //   (a) Cardboard apps on pre-integration Unity versions - they must have GvrViewerMain in a scene.
        //   (b) Daydream apps - these must be on GVR-integrated Unity versions, and must have GvrControllerMain.
        // Cardboard-only apps on the native integration are likely to have GvrViewerMain in their scene; otherwise,
        // the line below can be added to any script of the developer's choice.
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

#if OVERRIDE_GVR_WITH_OPENVR
        gameObject.AddComponent <SteamVR_TrackedControllerExtended>();
        gameObject.AddComponent <SteamVR_TrackedObjectExtended>();
        openVRController = gameObject.AddComponent <GvrOpenVRController>();
#endif
    }
    void Awake()
    {
        if (instance != null) {
          Debug.LogError("More than one GvrController instance was found in your scene. "
          + "Ensure that there is only one GvrController.");
          this.enabled = false;
          return;
        }
        instance = this;
        if (controllerProvider == null) {
          controllerProvider = ControllerProviderFactory.CreateControllerProvider(this);
        }

        // Keep screen on here, in case there isn't a GvrViewerMain prefab in the scene.
        // This ensures the behaviour for:
        //   (a) Cardboard apps on pre-integration Unity versions - they must have GvrViewerMain in a scene.
        //   (b) Daydream apps - these must be on GVR-integrated Unity versions, and must have GvrControllerMain.
        // Cardboard-only apps on the native integration are likely to have GvrViewerMain in their scene; otherwise,
        // the line below can be added to any script of the developer's choice.
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        #if OVERRIDE_GVR_WITH_OPENVR
        gameObject.AddComponent<SteamVR_TrackedControllerExtended>();
        gameObject.AddComponent<SteamVR_TrackedObjectExtended>();
        openVRController = gameObject.AddComponent<GvrOpenVRController>();
        #endif
    }