private void RenderExternalCamera() { if (externalCamera == null) { return; } if (!externalCamera.gameObject.activeInHierarchy) { return; } var frameSkip = (int)Mathf.Max(externalCamera.config.frameSkip, 0.0f); if (Time.frameCount % (frameSkip + 1) != 0) { return; } // Keep external camera relative to the most relevant vr camera. externalCamera.AttachToCamera(TopInternal()); externalCamera.RenderNear(); externalCamera.RenderFar(); }
private void InternalSetQuadViewActive(bool value) { if (value && m_externalCamera == null && !string.IsNullOrEmpty(m_configPath) && File.Exists(m_configPath)) { // don't know why SteamVR_ExternalCamera must be instantiated from the prefab // when create SteamVR_ExternalCamera using AddComponent, errors came out when disabling var prefab = Resources.Load <GameObject>("SteamVR_ExternalCamera"); if (prefab == null) { Debug.LogError("SteamVR_ExternalCamera prefab not found!"); } else { var ctrlMgr = Instantiate(prefab); var extCam = ctrlMgr.transform.GetChild(0); extCam.gameObject.name = "SteamVR External Camera"; extCam.SetParent(transform, false); DestroyImmediate(extCam.GetComponent <SteamVR_TrackedObject>()); DestroyImmediate(ctrlMgr); m_externalCamera = extCam.GetComponent <SteamVR_ExternalCamera>(); SteamVR_Render.instance.externalCamera = m_externalCamera; // resolve config file m_externalCamera.enabled = false; m_externalCamera.configPath = m_configPath; m_externalCamera.ReadConfig(); m_externalCamera.enabled = true; // to preserve sceneResolutionScale on enabled // resolve RenderTexture m_externalCamera.AttachToCamera(SteamVR_Render.Top()); var w = Screen.width / 2; var h = Screen.height / 2; var cam = m_externalCamera.GetComponentInChildren <Camera>(); if (cam.targetTexture == null || cam.targetTexture.width != w || cam.targetTexture.height != h) { var tex = new RenderTexture(w, h, 24, RenderTextureFormat.ARGB32, QualitySettings.activeColorSpace == ColorSpace.Linear ? RenderTextureReadWrite.Linear : RenderTextureReadWrite.Default); tex.antiAliasing = QualitySettings.antiAliasing == 0 ? 1 : QualitySettings.antiAliasing; cam.targetTexture = tex; } } } if (m_externalCamera != null) { m_externalCamera.gameObject.SetActive(value); if (value) { VivePose.AddNewPosesListener(this); } else { VivePose.RemoveNewPosesListener(this); } } }
private void RenderExternalCamera() { if (!(externalCamera == null) && externalCamera.gameObject.activeInHierarchy) { int num = (int)Mathf.Max(externalCamera.config.frameSkip, 0f); if (Time.frameCount % (num + 1) == 0) { externalCamera.AttachToCamera(TopInternal()); externalCamera.RenderNear(); externalCamera.RenderFar(); } } }