Пример #1
0
        /// <summary>
        /// Starts this instance.Use this for initialization
        /// </summary>
        void Start()
        {
            _btnPair   = transform.Find("Panel/Pair").gameObject;
            _btnUnpair = transform.Find("Panel/Unpair").gameObject;

            _handle_bg_1    = transform.Find("Panel/handle_bg_1").gameObject;
            _handle_bg_2    = transform.Find("Panel/handle_bg_2").gameObject;
            _handle_bg_3    = transform.Find("Panel/handle_bg_3").gameObject;
            _handle_bg_4    = transform.Find("Panel/handle_bg_4").gameObject;
            _textDeviceName = transform.Find("Panel/Text").gameObject;

            _btnUnpair.SetActive(false);
            _handle_bg_1.SetActive(false);
            _handle_bg_2.SetActive(false);
            _handle_bg_3.SetActive(false);
            _handle_bg_4.SetActive(false);

            // add message listener for message on flip connected
            DpnDaydreamController.onConnected += OnPeripheralConnected;

            string deviceName = DpnDaydreamController.GetBondDeviceName();

            if (deviceName != "")
            {
                _paired = true;
                _btnPair.SetActive(false);
                _btnUnpair.SetActive(true);
                SetCurrent(_handle_bg_4);
                SetDeviceName(deviceName);
            }
        }
Пример #2
0
        public void OnEnable()
        {
            if (instance != null)
            {
                Debug.LogError("More than one DpnController instance was found in your scene. "
                               + "Ensure that there is only one DpnController.");
                instance.enabled = false;
            }
            //string deviceName = "WiseVision_DayDream_Controller";
            string deviceName = null;

            if (DpnManager.peripheral == DPVRPeripheral.Flip)
            {
                deviceName = "SkyWorth_DayDream_Controller";
            }
            if (!OpenPeripheral(deviceName))
            {
                Debug.Log("Open Peripheral " + deviceName + " fails.");
                return;
            }

            instance = this;

            if (DpnManager.DPVRPointer)
            {
                raycaster             = this.gameObject.AddComponent <DpnPointerPhysicsRaycaster>();
                raycaster.raycastMode = DpnBasePointerRaycaster.RaycastMode.Camera;
                raycaster.enabled     = false;

                Pointer = Instantiate(reticlePointer);
                Pointer.SetParent(this.transform);
                Pointer.transform.localPosition = new Vector3(0.0f, 0.0f, 2.0f);
                Pointer.gameObject.SetActive(false);
            }
        }
Пример #3
0
        /// <summary>
        /// Enables this controller.
        /// </summary>
        public void OnEnable()
        {
            if (instance != null)
            {
                Debug.LogError("More than one DpnController instance was found in your scene. "
                               + "Ensure that there is only one DpnController.");
                instance.enabled = false;
            }
            //string deviceName = "WiseVision_DayDream_Controller";
            string deviceName = null;

            if (DpnManager.peripheral == DPVRPeripheral.Flip)
            {
                deviceName = "SkyWorth_DayDream_Controller";
            }
            if (!OpenPeripheral(deviceName))
            {
                Debug.Log("Open Peripheral " + deviceName + " fails.");
                return;
            }

            instance = this;

            if (DpnManager.DPVRPointer)
            {
                Pointer = Instantiate(reticlePointer);
                Pointer.SetParent(this.transform, false);
                Pointer.gameObject.SetActive(false);
                DpnBasePointer pointer = Pointer.GetComponent <DpnBasePointer>();
                if (pointer)
                {
                    pointer.SetTitledAngle(-15.0f);
                }
            }
        }
Пример #4
0
 public override void OnDisable()
 {
     base.OnDisable();
     if (instance == this)
     {
         instance = null;
     }
 }
Пример #5
0
        void OnPairFailed()
        {
            SetCurrent(_handle_bg_3);
            _btnPair.SetActive(true);
            _btnUnpair.SetActive(false);
            SetDeviceName("");

            // Notify the system to stop boot pair
            DpnDaydreamController.StopBootPair();
        }
Пример #6
0
        void OnUnpair()
        {
            _paired = false;
            _btnUnpair.SetActive(false);
            _btnPair.SetActive(false);
            ResetTips();
            SetDeviceName("");

            // unbind controller
            DpnDaydreamController.Unbind();
        }
Пример #7
0
        void OnPairStart()
        {
            SetCurrent(_handle_bg_1);
            _btnUnpair.SetActive(false);
            _btnPair.SetActive(false);

            // Notify the system to start boot pair
            DpnDaydreamController.StartBootPair();

            _bootPairOvertime = _BootPairOvertime();
            StartCoroutine(_bootPairOvertime);
        }
Пример #8
0
        void OnPairSucceed()
        {
            _paired = true;
            _btnPair.SetActive(false);
            _btnUnpair.SetActive(true);
            SetCurrent(_handle_bg_4);

            if (_bootPairOvertime != null)
            {
                StopCoroutine(_bootPairOvertime);
                _bootPairOvertime = null;
            }

            // Notify the system to stop boot pair
            DpnDaydreamController.StopBootPair();

            // get paired device name
            string name = DpnDaydreamController.GetBondDeviceName();

            SetDeviceName(name);
        }