public override void NewFrameStarting(RecordingSession session) { m_InputStrategy.UnsetupCamera(); switch (cbSettings.source) { case ImageSource.ActiveCamera: { if (targetCamera == null) { var displayGO = new GameObject(); displayGO.name = "CameraHostGO-" + displayGO.GetInstanceID(); displayGO.transform.parent = session.recorderGameObject.transform; var camera = displayGO.AddComponent <Camera>(); camera.clearFlags = CameraClearFlags.Nothing; camera.cullingMask = 0; camera.renderingPath = RenderingPath.DeferredShading; camera.targetDisplay = 0; camera.rect = new Rect(0, 0, 1, 1); camera.depth = float.MaxValue; targetCamera = camera; } break; } case ImageSource.MainCamera: { targetCamera = Camera.main; break; } case ImageSource.TaggedCamera: { var tag = ((CameraInputSettings)settings).cameraTag; if (targetCamera == null || !targetCamera.gameObject.CompareTag(tag)) { try { var objs = GameObject.FindGameObjectsWithTag(tag); var cams = objs.Select(obj => obj.GetComponent <Camera>()).Where(c => c != null); if (cams.Count() > 1) { Debug.LogWarning("More than one camera has the requested target tag '" + tag + "'"); } targetCamera = cams.FirstOrDefault(); } catch (UnityException) { Debug.LogWarning("No camera has the requested target tag '" + tag + "'"); targetCamera = null; } } break; } } PrepFrameRenderTexture(); m_InputStrategy.SetupCamera(outputRT); }
/// <inheritdoc/> protected internal override void NewFrameStarting(RecordingSession session) { m_InputStrategy.UnsetupCamera(); switch (cbSettings.Source) { case ImageSource.ActiveCamera: { if (TargetCamera == null) { var displayGO = new GameObject(); displayGO.name = "CameraHostGO-" + displayGO.GetInstanceID(); displayGO.transform.parent = session.recorderGameObject.transform; var camera = displayGO.AddComponent <Camera>(); camera.clearFlags = CameraClearFlags.Nothing; camera.cullingMask = 0; camera.renderingPath = RenderingPath.DeferredShading; camera.targetDisplay = 0; camera.rect = new Rect(0, 0, 1, 1); camera.depth = float.MaxValue; TargetCamera = camera; } break; } case ImageSource.MainCamera: { TargetCamera = Camera.main; break; } case ImageSource.TaggedCamera: { var tag = ((CameraInputSettings)settings).CameraTag; if (TargetCamera == null || !TargetCamera.gameObject.CompareTag(tag)) { try { var objs = GameObject.FindGameObjectsWithTag(tag); var cams = objs.Select(obj => obj.GetComponent <Camera>()).Where(c => c != null); if (cams.Count() > 1) { Debug.LogWarning("More than one camera has the requested target tag '" + tag + "'"); } TargetCamera = cams.FirstOrDefault(); } catch (UnityException) { Debug.LogWarning("No camera has the requested target tag '" + tag + "'"); TargetCamera = null; } } break; } } PrepFrameRenderTexture(session); bool needToFlip = true; var movieRecorderSettings = session.recorder.settings as MovieRecorderSettings; if (movieRecorderSettings != null) { var encoderAlreadyFlips = movieRecorderSettings.encodersRegistered[movieRecorderSettings.encoderSelected].PerformsVerticalFlip; needToFlip = encoderAlreadyFlips; } if (CameraInputSettings.UsingLegacyRP()) { m_InputStrategy.flipVertically = needToFlip; // regular pipeline } else { m_InputStrategy.flipVertically = !needToFlip; // scriptable render pipeline already flips input } m_InputStrategy.SetupCamera(OutputRenderTexture); }