void StartRecording(bool autoExitPlayMode) { var settings = (RecorderSettings)m_Editor.target; var go = FrameRecorderGOControler.HookupRecorder(!settings.m_Verbose); var session = new RecordingSession() { m_Recorder = RecordersInventory.GenerateNewRecorder(m_recorderSelector.selectedRecorder, settings), m_RecorderGO = go, }; var component = go.AddComponent <RecorderComponent>(); component.session = session; component.autoExitPlayMode = autoExitPlayMode; if (session.SessionCreated() && session.BeginRecording()) { m_State = EState.Recording; } else { m_State = EState.Idle; StopRecording(); } }
void RecordButtonOnGui() { if (m_Editor == null || m_Editor.target == null) { return; } switch (m_State) { case EState.Idle: { using (new EditorGUI.DisabledScope(!m_Editor.isValid)) { if (GUILayout.Button("Start Recording")) { StartRecording(); } } break; } case EState.WaitingForPlayModeToStartRecording: { using (new EditorGUI.DisabledScope(true)) GUILayout.Button("Stop Recording"); // passive break; } case EState.Recording: { var recorderGO = FrameRecorderGOControler.FindRecorder((RecorderSettings)m_Editor.target); if (recorderGO == null) { GUILayout.Button("Start Recording"); // just to keep the ui system happy. m_State = EState.Idle; } else { if (GUILayout.Button("Stop Recording")) { StopRecording(); } UpdateRecordingProgress(recorderGO); } break; } default: throw new ArgumentOutOfRangeException(); } }
void StopRecording() { if (m_Editor != null) { var settings = (RecorderSettings)m_Editor.target; if (settings != null) { var recorderGO = FrameRecorderGOControler.FindRecorder(settings); if (recorderGO != null) { UnityHelpers.Destroy(recorderGO); } } } }
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner) { var playable = ScriptPlayable <RecorderPlayableBehaviour> .Create(graph); var behaviour = playable.GetBehaviour(); if (recorderType != null && UnityHelpers.IsPlaying()) { behaviour.session = new RecordingSession() { m_Recorder = RecordersInventory.GenerateNewRecorder(recorderType, m_Settings), m_RecorderGO = FrameRecorderGOControler.HookupRecorder(!m_Settings.m_Verbose), }; } return(playable); }
void StartRecording(bool autoExitPlayMode) { var settings = (RecorderSettings)m_Editor.target; var go = FrameRecorderGOControler.HookupRecorder(); var session = new RecordingSession() { m_Recorder = RecordersInventory.GenerateNewRecorder(m_recorderSelector.selectedRecorder, settings), m_RecorderGO = go, m_RecordingStartTS = Time.time / Time.timeScale, m_FrameIndex = 0 }; var component = go.AddComponent <RecorderComponent>(); component.session = session; component.autoExitPlayMode = autoExitPlayMode; session.BeginRecording(); m_State = EState.Recording; }