Пример #1
0
 public override Vector2 GetScreenPosition()
 {
     if (DpnUICamera.instance != null)
     {
         return(DpnUICamera.instance.centerCamera.WorldToScreenPoint(transform.position));
     }
     else
     {
         return(DpnCameraRig.WorldToScreenPoint(transform.position));
     }
 }
Пример #2
0
        /// <summary>
        /// invoked by Unity Engine
        /// disable this camera.
        /// </summary>
        public override void OnDisable()
        {
            IntPtr tempPtr = Marshal.StringToHGlobalAnsi("OnDisable");

            Composer.DpnuSetIntValue(tempPtr, 1);
            base.OnDisable();
            if (_instance == this)
            {
                _instance = null;
            }
        }
Пример #3
0
 private void OnDestroy()
 {
     instance = null;
 }
Пример #4
0
 private void Awake()
 {
     instance = this;
 }
Пример #5
0
 public Vector2 GetScreenPosition()
 {
     return(DpnCameraRig.WorldToScreenPoint(transform.position));
 }
Пример #6
0
        void InitPeripheral()
        {
            if (!CameraRigInit)
            {
#if UNITY_5_3_OR_NEWER || UNITY_5
                VRsupport = UnityEngine.VR.VRSettings.enabled;
#else
                VRsupport = false;
#endif
            }
            CameraRigInit = true;
            if (!Init())
            {
                return;
            }
            base.OnEnable();
            if (_instance != this && _instance != null)
            {
                Debug.LogWarning("There is another active DpnCameraRig in a scene, set it unactive");
                _instance.gameObject.SetActive(false);
            }
            _instance = this;
            _UpdateCam(DpnManager.DeviceInfo.fov_y
                       , DpnManager.DeviceInfo.fov_x / (float)DpnManager.DeviceInfo.fov_y);

            if (DpnManager.DPVRPointer)
            {
                DpnPointerPhysicsRaycaster raycaster = _center_transform.gameObject.AddComponent <DpnPointerPhysicsRaycaster>();
                raycaster.raycastMode = DpnBasePointerRaycaster.RaycastMode.Direct;
                raycaster.enabled     = true;

                Transform Pointer = Instantiate(reticlePointer);
                Pointer.SetParent(raycaster.transform);
                Pointer.transform.localPosition = new Vector3(0.0f, 0.0f, 2.0f);
                Pointer.gameObject.SetActive(true);

                _nonePointer   = Pointer.gameObject;
                _noneRaycaster = raycaster;
            }
            _hmdPeripheral = this;
            _hmdPeripheral.EnableInternalObjects(false);

            switch (DpnManager.peripheral)
            {
            case DPVRPeripheral.Polaris:
            {
                Transform Peripheral = Instantiate(Polaris);
                Peripheral.parent = this.transform;

                _defaultPeripheral = Peripheral.GetComponent <DpnMultiControllerPeripheralPolaris>();
                _defaultPeripheral.EnableInternalObjects(false);
                break;
            }

            case DPVRPeripheral.Nolo:
            {
                Transform Peripheral = Instantiate(Nolo);
                Peripheral.parent = this.transform;

                Transform boundary = Instantiate(Boundary);
                boundary.parent = this.transform;

                _defaultPeripheral = Peripheral.GetComponent <DpnMultiControllerPeripheralNolo>();
                _defaultPeripheral.EnableInternalObjects(false);
                break;
            }

            case DPVRPeripheral.Flip:
            {
                Transform Peripheral = Instantiate(Flip);
                Peripheral.parent        = this.transform;
                Peripheral.localPosition = Vector3.zero;

                Transform controller_right = Peripheral.Find("controller(right)");
                if (controller_right == null)
                {
                    break;
                }

                _defaultPeripheral = controller_right.GetComponent <DpnDaydreamController>();
                _defaultPeripheral.EnableInternalObjects(false);

                break;
            }

            case DPVRPeripheral.None:
            {
                _defaultPeripheral = _hmdPeripheral;
                break;
            }

            default:
                break;
            }

            SetPeripheral(_defaultPeripheral);
        }