Пример #1
0
        private void enableVrCamera()
        {
            if (_instance == null)
            {
                LogError("Cannot enable VR Camera with null SteamVR Player instance.");
                return;
            }
            Camera mainCamera = CameraUtils.getCamera(CameraUtils.MAIN_CAMERA);

            if (mainCamera == null)
            {
                LogError("Main Camera is null.");
                return;
            }
            Camera vrCam = CameraUtils.getCamera(CameraUtils.VR_CAMERA);

            CameraUtils.copyCamera(mainCamera, vrCam);
            maybeCopyPostProcessingEffects(vrCam, mainCamera);
            maybeAddAmplifyOcclusion(vrCam);
            // Prevent visibility of the head
            vrCam.nearClipPlane = VHVRConfig.GetNearClipPlane();
            // Turn off rendering the UI panel layer. We need to capture
            // it in a camera of higher depth so that it
            // is rendered on top of everything else. (except hands)
            vrCam.cullingMask &= ~(1 << LayerUtils.getUiPanelLayer());
            vrCam.cullingMask &= ~(1 << LayerMask.NameToLayer("UI"));
            vrCam.cullingMask &= ~(1 << LayerUtils.getHandsLayer());
            vrCam.cullingMask &= ~(1 << LayerUtils.getWorldspaceUiLayer());
            mainCamera.enabled = false;
            AudioListener mainCamListener = mainCamera.GetComponent <AudioListener>();

            if (mainCamListener != null)
            {
                LogDebug("Destroying MainCamera AudioListener");
                DestroyImmediate(mainCamListener);
            }
            //Add fade component to camera for transition handling
            _fadeManager = vrCam.gameObject.AddComponent <FadeToBlackManager>();
            _instance.SetActive(true);
            vrCam.enabled = true;
            _vrCam        = vrCam;
            _vrCameraRig  = vrCam.transform.parent;

            _fadeManager.OnFadeToWorld += () => {
                //Recenter
                VRPlayer.headPositionInitialized = false;
                VRPlayer.vrPlayerInstance?.ResetRoomscaleCamera();
            };
        }
Пример #2
0
        private static int getCrosshairRaycastLayerMask()
        {
            int mask = Physics.DefaultRaycastLayers;

            // Ignore these layers
            mask &= ~(1 << 14); // character_trigger
            mask &= ~(1 << 21); // WaterVolume
            mask &= ~(1 << 4);  // Water
            mask &= ~(1 << 25); // viewblock
            mask &= ~(1 << 31); // smoke
            mask &= ~(1 << 5);  // UI
            mask &= ~(1 << 24); // pathblocker
            mask &= ~(1 << LayerUtils.getUiPanelLayer());
            mask &= ~(1 << LayerUtils.getHandsLayer());
            mask &= ~(1 << LayerUtils.getWorldspaceUiLayer());
            return(mask);
        }