示例#1
0
 private void Awake()
 {
     leftHand             = this.FindComponent <ActionBasedControllerManager>("XR Origin/Camera Offset/LeftHand");
     rightHand            = this.FindComponent <ActionBasedControllerManager>("XR Origin/Camera Offset/RightHand");
     _interactionManager  = this.FindComponent <XRInteractionManager>("XR Interaction Manager");
     locomotionSystem     = this.FindGameObject("Locomotion System");
     _mainCamera          = this.FindComponent <Camera>("XR Origin/Camera Offset/Main Camera");
     leftXRRayInteractor  = LeftController.GetComponent <XRRayInteractor>();
     rightXRRayInteractor = RightController.GetComponent <XRRayInteractor>();
 }
    private void ChangeCanvasEventCamera(WVR_DeviceType _dt)
    {
        var _objects = GameObject.FindGameObjectsWithTag(CanvasTag);

        if (_objects == null)
        {
            #if UNITY_EDITOR
            Debug.Log("WaveVR_CombinedInputModule::ChangeCanvasEventCamera, objects with tag [" + CanvasTag + "] are not found.");
            #endif
            Log.e(LOG_TAG, "ChangeCanvasEventCamera, objects with tag [" + CanvasTag + "] are not found.");
            return;
        }

        Camera _event_camera = null;
        switch (_dt)
        {
        case WVR_DeviceType.WVR_DeviceType_Controller_Right:
            _event_camera = (Camera)RightController.GetComponent(typeof(Camera));
            break;

        case WVR_DeviceType.WVR_DeviceType_Controller_Left:
            _event_camera = (Camera)LeftController.GetComponent(typeof(Camera));
            break;

        default:
            _event_camera = (Camera)GazeCamera.GetComponent(typeof(Camera));
            break;
        }

        if (_event_camera == null)
        {
            #if UNITY_EDITOR
            Debug.Log("WaveVR_CombinedInputModule::ChangeCanvasEventCamera, no event camera!");
            #endif
            Log.e(LOG_TAG, "ChangeCanvasEventCamera, no event camera!");
            return;
        }

        foreach (GameObject o in _objects)
        {
            Canvas _canvas = (Canvas)o.GetComponent(typeof(Canvas));
            if (_canvas != null)
            {
                if (_dt != WVR_DeviceType.WVR_DeviceType_HMD)
                {
                    Log.d(LOG_TAG, "Change " + _canvas.name + " canvas event camera to " + _dt);
                }
                _canvas.worldCamera = _event_camera;
            }
        }
    }
示例#3
0
    private void PhysicRaycast_Left()
    {
        Camera           _cam       = (Camera)LeftController.GetComponent(typeof(Camera));
        PhysicsRaycaster _raycaster = LeftController.GetComponent <PhysicsRaycaster> ();

        if (_cam == null || _raycaster == null)
        {
            Log.e(LOG_TAG, "PhysicRaycast_Left() no Camera or Physics Raycaster!");
            return;
        }

        if (leftHandPointer == null)
        {
            leftHandPointer = new PointerEventData(eventSystem);
        }

        leftHandPointer.Reset();
        leftHandPointer.position = new Vector2(0.5f * Screen.width, 0.5f * Screen.height);   // center of screen

        List <RaycastResult> _results = new List <RaycastResult>();

        if (_raycaster != null)
        {
            _raycaster.Raycast(leftHandPointer, _results);
        }

        RaycastResult _firstResult = FindFirstRaycast(_results);

        if (_firstResult.module != null)
        {
            #if UNITY_EDITOR
            //Debug.Log ("PhysicRaycast_Left(), camera: " + _firstResult.module.eventCamera + ", first result = " + _firstResult);
            #endif
            //Log.d (LOG_TAG, "PhysicRaycast_Left(), camera: " + _firstResult.module.eventCamera + ", first result = " + _firstResult);
        }

        leftHandPointer.pointerCurrentRaycast = _firstResult;
        if (_firstResult.gameObject != null)
        {
            leftHandPointer.position = _firstResult.screenPosition;
        }
    }