Esempio n. 1
0
    public void whatAreWe()
    {
        #if UNITY_EDITOR
        if (playerSettingsHasDaydream() || playerSettingsHasCardboard())
        {
            // The list is populated with valid VR SDK(s), pick the first one.
            gvrEmulatedPlatformType =
                (UnityEngine.VR.VRSettings.supportedDevices[0] == DAYDREAM_DEVICE_NAME) ?
                EmulatedPlatformType.Daydream :
                EmulatedPlatformType.Cardboard;
        }
        isDaydream = (gvrEmulatedPlatformType == EmulatedPlatformType.Daydream);
        #else
        // First loaded device in Player Settings.
        string vrDeviceName = UnityEngine.VR.VRSettings.loadedDeviceName;
        if (vrDeviceName != CARDBOARD_DEVICE_NAME &&
            vrDeviceName != DAYDREAM_DEVICE_NAME)
        {
            Debug.Log(string.Format("Loaded device was {0} must be one of {1} or {2}",
                                    vrDeviceName, DAYDREAM_DEVICE_NAME, CARDBOARD_DEVICE_NAME));
            return;
        }

        // On a non-Daydream ready phone, fall back to Cardboard if it's present in the
        // list of enabled VR SDKs.
        if (!IsDeviceDaydreamReady() && playerSettingsHasCardboard())
        {
            vrDeviceName = CARDBOARD_DEVICE_NAME;
        }
        isDaydream = (vrDeviceName == DAYDREAM_DEVICE_NAME);
        #endif  // UNITY_EDITOR
    }
Esempio n. 2
0
        void Start()
        {
            //mybutton.onClick.AddListener(TaskOnClick);
            if (mybutton)
            {
                Debug.Log(mybutton.name);
            }
            else
            {
                Debug.Log("No game object called wibble found");
            }
            try{
                if (messageCanvas == null)
                {
                    messageCanvas = transform.Find(MESSAGE_CANVAS_NAME).gameObject;
                    if (messageCanvas != null)
                    {
                        messageText = messageCanvas.transform.Find(MESSAGE_TEXT_NAME).GetComponent <Text>();
                    }
                }
            }
            catch (Exception e) {}
            // Message canvas will be enabled later when there's a message to display.
            messageCanvas.SetActive(false);
#if !RUNNING_ON_ANDROID_DEVICE
            if (playerSettingsHasDaydream() || playerSettingsHasCardboard())
            {
                // The list is populated with valid VR SDK(s), pick the first one.
                gvrEmulatedPlatformType =
                    (XRSettings.supportedDevices[0] == GvrSettings.VR_SDK_DAYDREAM) ?
                    EmulatedPlatformType.Daydream :
                    EmulatedPlatformType.Cardboard;
            }
            isDaydream = (gvrEmulatedPlatformType == EmulatedPlatformType.Daydream);
#else
            // Running on an Android device.
            viewerPlatform = GvrSettings.ViewerPlatform;
            // First loaded device in Player Settings.
            string vrDeviceName = XRSettings.loadedDeviceName;
            if (vrDeviceName != GvrSettings.VR_SDK_CARDBOARD &&
                vrDeviceName != GvrSettings.VR_SDK_DAYDREAM)
            {
                Debug.LogErrorFormat("Loaded device was '{0}', must be one of '{1}' or '{2}'",
                                     vrDeviceName, GvrSettings.VR_SDK_DAYDREAM, GvrSettings.VR_SDK_CARDBOARD);
                return;
            }

            // On a non-Daydream ready phone, fall back to Cardboard if it's present in the list of
            // enabled VR SDKs.
            // On a Daydream-ready phone, go into Cardboard mode if it's the currently-paired viewer.
            if ((!IsDeviceDaydreamReady() && playerSettingsHasCardboard()) ||
                (IsDeviceDaydreamReady() && playerSettingsHasCardboard() &&
                 GvrSettings.ViewerPlatform == GvrSettings.ViewerPlatformType.Cardboard))
            {
                vrDeviceName = GvrSettings.VR_SDK_CARDBOARD;
            }
            isDaydream = (vrDeviceName == GvrSettings.VR_SDK_DAYDREAM);
#endif  // !RUNNING_ON_ANDROID_DEVICE
            SetVRInputMechanism();
        }
  void Start() {
    if (messageCanvas == null) {
      messageCanvas = transform.Find(MESSAGE_CANVAS_NAME).gameObject;
      if (messageCanvas != null) {
        messageText = messageCanvas.transform.Find(MESSAGE_TEXT_NAME).GetComponent<Text>();
      }
    }
#if UNITY_EDITOR
    if (playerSettingsHasDaydream() || playerSettingsHasCardboard()) {
      // The list is populated with valid VR SDK(s), pick the first one.
      gvrEmulatedPlatformType =
        (UnityEngine.VR.VRSettings.supportedDevices[0] == DAYDREAM_DEVICE_NAME) ?
        EmulatedPlatformType.Daydream :
        EmulatedPlatformType.Cardboard;
    }
    isDaydream = (gvrEmulatedPlatformType == EmulatedPlatformType.Daydream);
#else
    // First loaded device in Player Settings.
    string vrDeviceName = UnityEngine.VR.VRSettings.loadedDeviceName;
    if (vrDeviceName != CARDBOARD_DEVICE_NAME &&
        vrDeviceName != DAYDREAM_DEVICE_NAME) {
      Debug.Log(string.Format("Loaded device was {0} must be one of {1} or {2}",
            vrDeviceName, DAYDREAM_DEVICE_NAME, CARDBOARD_DEVICE_NAME));
      return;
    }

    // On a non-Daydream ready phone, fall back to Cardboard if it's present in the
    // list of enabled VR SDKs.
    if (!IsDeviceDaydreamReady() && playerSettingsHasCardboard()) {
      vrDeviceName = CARDBOARD_DEVICE_NAME;
    }
    isDaydream = (vrDeviceName == DAYDREAM_DEVICE_NAME);
#endif  // UNITY_EDITOR
    SetVRInputMechanism();
  }
Esempio n. 4
0
    void Start()
    {
        /*if (messageCanvas == null) {
         * messageCanvas = transform.Find(MESSAGE_CANVAS_NAME).gameObject;
         * if (messageCanvas != null) {
         *  messageText = messageCanvas.transform.Find(MESSAGE_TEXT_NAME).GetComponent<Text>();
         * }
         * }*/
        // Message canvas will be enabled later when there's a message to display.
        //messageCanvas.SetActive(false);
#if !RUNNING_ON_ANDROID_DEVICE
        if (playerSettingsHasDaydream() || playerSettingsHasCardboard())
        {
            // The list is populated with valid VR SDK(s), pick the first one.
            gvrEmulatedPlatformType =
                (UnityEngine.VR.VRSettings.supportedDevices[0] == DAYDREAM_DEVICE_NAME) ?
                EmulatedPlatformType.Daydream :
                EmulatedPlatformType.Cardboard;
        }
        isDaydream = (gvrEmulatedPlatformType == EmulatedPlatformType.Daydream);
#else
        // Running on an Android device.
        viewerPlatform = GvrSettings.ViewerPlatform;
        // First loaded device in Player Settings.
        string vrDeviceName = UnityEngine.VR.VRSettings.loadedDeviceName;
        if (vrDeviceName != CARDBOARD_DEVICE_NAME &&
            vrDeviceName != DAYDREAM_DEVICE_NAME)
        {
            Debug.LogErrorFormat("Loaded device was '{0}', must be one of '{1}' or '{2}'",
                                 vrDeviceName, DAYDREAM_DEVICE_NAME, CARDBOARD_DEVICE_NAME);
            return;
        }

        // On a non-Daydream ready phone, fall back to Cardboard if it's present in the list of
        // enabled VR SDKs.
        // On a Daydream-ready phone, go into Cardboard mode if it's the currently-paired viewer.
        if ((!IsDeviceDaydreamReady() && playerSettingsHasCardboard()) ||
            (IsDeviceDaydreamReady() && playerSettingsHasCardboard() &&
             GvrSettings.ViewerPlatform == GvrSettings.ViewerPlatformType.Cardboard))
        {
            vrDeviceName = CARDBOARD_DEVICE_NAME;
        }
        isDaydream = (vrDeviceName == DAYDREAM_DEVICE_NAME);
#endif  // !RUNNING_ON_ANDROID_DEVICE
        SetVRInputMechanism();
    }
Esempio n. 5
0
    void Start()
    {
        Input.backButtonLeavesApp = true;
        if (messageCanvas == null)
        {
            messageCanvas = transform.Find(MESSAGE_CANVAS_NAME).gameObject;
            if (messageCanvas != null)
            {
                messageText = messageCanvas.transform.Find(MESSAGE_TEXT_NAME).GetComponent <Text>();
            }
        }
#if UNITY_EDITOR
        if (playerSettingsHasDaydream() || playerSettingsHasCardboard())
        {
            // The list is populated with valid VR SDK(s), pick the first one.
            gvrEmulatedPlatformType =
                (UnityEngine.XR.XRSettings.supportedDevices[0] == DAYDREAM_DEVICE_NAME) ?
                EmulatedPlatformType.Daydream :
                EmulatedPlatformType.Cardboard;
        }
        isDaydream = (gvrEmulatedPlatformType == EmulatedPlatformType.Daydream);
#else
        viewerPlatform = GvrSettings.ViewerPlatform;
        // First loaded device in Player Settings.
        string vrDeviceName = UnityEngine.VR.VRSettings.loadedDeviceName;
        if (vrDeviceName != CARDBOARD_DEVICE_NAME &&
            vrDeviceName != DAYDREAM_DEVICE_NAME)
        {
            Debug.Log(string.Format("Loaded device was {0} must be one of {1} or {2}",
                                    vrDeviceName, DAYDREAM_DEVICE_NAME, CARDBOARD_DEVICE_NAME));
            return;
        }

        // On a non-Daydream ready phone, fall back to Cardboard if it's present in the list of
        // enabled VR SDKs.
        // On a Daydream-ready phone, go into Cardboard mode if it's the currently-paired viewer.
        if ((!IsDeviceDaydreamReady() && playerSettingsHasCardboard()) ||
            (IsDeviceDaydreamReady() && playerSettingsHasCardboard() &&
             GvrSettings.ViewerPlatform == GvrSettings.ViewerPlatformType.Cardboard))
        {
            vrDeviceName = CARDBOARD_DEVICE_NAME;
        }
        isDaydream = (vrDeviceName == DAYDREAM_DEVICE_NAME);
#endif  // UNITY_EDITOR
        SetVRInputMechanism();
    }
    private void UpdateEmulatedPlatformIfPlayerSettingsChanged()
    {
        if (!playerSettingsHasDaydream() && !playerSettingsHasCardboard())
        {
            return;
        }

        // Player Settings > VR SDK list may have changed at runtime. The emulated platform
        // may not have been manually updated if that's the case.
        if (gvrEmulatedPlatformType == EmulatedPlatformType.Daydream &&
            !playerSettingsHasDaydream())
        {
            gvrEmulatedPlatformType = EmulatedPlatformType.Cardboard;
        }
        else if (gvrEmulatedPlatformType == EmulatedPlatformType.Cardboard &&
                 !playerSettingsHasCardboard())
        {
            gvrEmulatedPlatformType = EmulatedPlatformType.Daydream;
        }
    }
Esempio n. 7
0
    void Start()
    {
#if !RUNNING_ON_ANDROID_DEVICE
        if (playerSettingsHasDaydream() || playerSettingsHasCardboard())
        {
            // The list is populated with valid VR SDK(s), pick the first one.
            gvrEmulatedPlatformType =
                (XRSettings.supportedDevices[0] == GvrSettings.VR_SDK_DAYDREAM) ?
                EmulatedPlatformType.Daydream :
                EmulatedPlatformType.Cardboard;
        }
        isDaydream = (gvrEmulatedPlatformType == EmulatedPlatformType.Daydream);
#else
        // Running on an Android device.
        viewerPlatform = GvrSettings.ViewerPlatform;
        // First loaded device in Player Settings.
        string vrDeviceName = XRSettings.loadedDeviceName;
        if (vrDeviceName != GvrSettings.VR_SDK_CARDBOARD &&
            vrDeviceName != GvrSettings.VR_SDK_DAYDREAM)
        {
            Debug.LogErrorFormat("Loaded device was '{0}', must be one of '{1}' or '{2}'",
                                 vrDeviceName, GvrSettings.VR_SDK_DAYDREAM, GvrSettings.VR_SDK_CARDBOARD);
            return;
        }

        // On a non-Daydream ready phone, fall back to Cardboard if it's present in the list of
        // enabled VR SDKs.
        // On a Daydream-ready phone, go into Cardboard mode if it's the currently-paired viewer.
        if ((!IsDeviceDaydreamReady() && playerSettingsHasCardboard()) ||
            (IsDeviceDaydreamReady() && playerSettingsHasCardboard() &&
             GvrSettings.ViewerPlatform == GvrSettings.ViewerPlatformType.Cardboard))
        {
            vrDeviceName = GvrSettings.VR_SDK_CARDBOARD;
        }
        isDaydream = (vrDeviceName == GvrSettings.VR_SDK_DAYDREAM);
#endif  // !RUNNING_ON_ANDROID_DEVICE
        SetVRInputMechanism();
    }
  private void UpdateEmulatedPlatformIfPlayerSettingsChanged() {
    if (!playerSettingsHasDaydream() && !playerSettingsHasCardboard()) {
      return;
    }

    // Player Settings > VR SDK list may have changed at runtime. The emulated platform
    // may not have been manually updated if that's the case.
    if (gvrEmulatedPlatformType == EmulatedPlatformType.Daydream &&
        !playerSettingsHasDaydream()) {
      gvrEmulatedPlatformType = EmulatedPlatformType.Cardboard;
    } else if (gvrEmulatedPlatformType == EmulatedPlatformType.Cardboard &&
               !playerSettingsHasCardboard()) {
      gvrEmulatedPlatformType = EmulatedPlatformType.Daydream;
    }
  }