Ejemplo n.º 1
0
    void Awake()
    {
        if (instances.Length > 0)
        {
            Debug.LogError("More than one active GvrControllerInput instance was found in your scene. "
                           + "Ensure that there is only one GvrControllerInput.");
            this.enabled = false;
            return;
        }
        if (controllerProvider == null)
        {
            controllerProvider = ControllerProviderFactory.CreateControllerProvider(this);
        }

        handedness = GvrSettings.Handedness;
        int controllerCount = 2;

        instances = new GvrControllerInputDevice[controllerCount];
        for (int i = 0; i < controllerCount; i++)
        {
            instances[i] = new GvrControllerInputDevice(controllerProvider, i);
        }
        if (onDevicesChangedInternal != null)
        {
            onDevicesChangedInternal();
        }

        // Keep screen on here, since GvrControllerInput must be in any GVR scene in order to enable
        // controller capabilities.
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
    }
Ejemplo n.º 2
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
    }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
0
    void Awake()
    {
        if (instance != null)
        {
            Debug.LogError("More than one GvrController instance was found in your scene. "
                           + "Ensure that there is only one GvrControllerInput.");
            this.enabled = false;
            return;
        }
        instance = this;
        if (controllerProvider == null)
        {
            controllerProvider = ControllerProviderFactory.CreateControllerProvider(this);
        }

        // Keep screen on here, since GvrController must be in any GVR scene in order to enable
        // controller capabilities.
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
    }