示例#1
0
        protected override void OnAwake()
        {
            VRLog.Debug("Creating VR Camera");
            _Camera = gameObject.AddComponent <Camera>();
            gameObject.AddComponent <SteamVR_Camera>();
            SteamCam = GetComponent <SteamVR_Camera>();
            SteamCam.Expand(); // Expand immediately!

            if (!VR.Settings.MirrorScreen)
            {
                Destroy(SteamCam.head.GetComponent <SteamVR_GameView>());
                Destroy(SteamCam.head.GetComponent <Camera>()); // Save GPU power
            }

            // Set render scale to the value defined by the user
            SteamVR_Camera.sceneResolutionScale = VR.Settings.RenderScale;

            // Needed for the Camera Modifications mod to work. It's an artifact from DK2 days
            var legacyAnchor = new GameObject("CenterEyeAnchor");

            legacyAnchor.transform.SetParent(SteamCam.head);

            DontDestroyOnLoad(SteamCam.origin.gameObject);
        }
示例#2
0
        /// <summary>
        /// Copies the values of a in-game camera to the VR camera.
        /// </summary>
        /// <param name="blueprint">The camera to copy.</param>
        public void Copy(Camera blueprint, bool master = false, bool hasOtherConsumers = false)
        {
            VRLog.Info("Copying camera: {0}", blueprint ? blueprint.name : "NULL");

            if (blueprint && blueprint.GetComponent <CameraSlave>())
            {
                VRLog.Warn("Is already slave -- NOOP");
                return;
            }

            if (master && UseNewCamera(blueprint))
            {
                _Blueprint = blueprint ?? _Camera;

                // Apply to both the head camera and the VR camera
                ApplyToCameras(targetCamera =>
                {
                    targetCamera.nearClipPlane = VR.Context.NearClipPlane / 100;
                    targetCamera.farClipPlane  = Mathf.Max(Blueprint.farClipPlane, MIN_FAR_CLIP_PLANE);
                    targetCamera.clearFlags    = Blueprint.clearFlags == CameraClearFlags.Skybox ? CameraClearFlags.Skybox : CameraClearFlags.SolidColor;
                    targetCamera.renderingPath = Blueprint.renderingPath;
                    targetCamera.clearStencilAfterLightingPass = Blueprint.clearStencilAfterLightingPass;
                    targetCamera.depthTextureMode    = Blueprint.depthTextureMode;
                    targetCamera.layerCullDistances  = Blueprint.layerCullDistances;
                    targetCamera.layerCullSpherical  = Blueprint.layerCullSpherical;
                    targetCamera.useOcclusionCulling = Blueprint.useOcclusionCulling;
                    targetCamera.hdr = false;

                    targetCamera.backgroundColor = Blueprint.backgroundColor;

                    var skybox = Blueprint.GetComponent <Skybox>();
                    if (skybox != null)
                    {
                        var vrSkybox = targetCamera.gameObject.GetComponent <Skybox>();
                        if (vrSkybox == null)
                        {
                            vrSkybox = targetCamera.gameObject.AddComponent <Skybox>();
                        }

                        vrSkybox.material = skybox.material;
                    }

                    foreach (var comp in blueprint.GetComponents <MonoBehaviour>())
                    {
                        if (targetCamera.gameObject.GetComponent(comp.GetType()) == null)
                        {
                            if (VR.Interpreter.IsAllowedEffect(comp))
                            {
                                VRLog.Debug("Copy FX " + comp.GetType().Name);
                                var cp       = targetCamera.gameObject.CopyComponentFrom(comp);
                                cp.enabled   = comp.enabled;
                                m_bFxEnabled = true;
                                FixEffectOrder();
                            }
                        }
                    }
                });
            }

            if (blueprint)
            {
                blueprint.gameObject.AddComponent <CameraSlave>();

                // Highlander principle
                var listener = blueprint.GetComponent <AudioListener>();
                if (listener)
                {
                    Destroy(listener);
                }

                if (!hasOtherConsumers && blueprint.targetTexture == null && VR.Interpreter.IsIrrelevantCamera(blueprint))
                {
                    //StartCoroutine(ExecuteDelayed(delegate { CopyFX(Blueprint); }));
                    //CopyFX(Blueprint);

                    blueprint.gameObject.AddComponent <CameraKiller>();
                    //blueprint.enabled = false;
                    //blueprint.nearClipPlane = Blueprint.farClipPlane = 0;

                    //Blueprint.targetTexture = _MiniTexture;
                    //Blueprint.gameObject.AddComponent<BlacklistThrottler>();
                }
            }

            if (master)
            {
                // Hook
                InitializeCamera(this, new InitializeCameraEventArgs(GetComponent <Camera>(), Blueprint));
            }

            CopiedCamera(this, new CopiedCameraEventArgs(blueprint));
        }
 protected virtual void Initialize(T actor)
 {
     Actor = actor;
     VRLog.Debug("Creating character {0}", actor.name);
 }
示例#4
0
 internal void UnregisterSlave(CameraSlave slave)
 {
     VRLog.Debug("Camera went offline: {0}", slave.name);
     Slaves.Remove(slave);
     UpdateCameraConfig();
 }
示例#5
0
 internal void RegisterSlave(CameraSlave slave)
 {
     VRLog.Debug("Camera went online: {0}", slave.name);
     Slaves.Add(slave);
     UpdateCameraConfig();
 }
示例#6
0
        protected override void OnLevel(int level)
        {
            base.OnLevel(level);

            VRLog.Debug("Loaded level {0}", level);
        }