void OnEnable() { InitializedPrefsIfNeeded(); _recordVideo = FindOrCreateRecordVideo(); _gui = new GUIVertical(); _gui.Add(new GUIButton(new GUIContent(FFmpegPathButtonText(), FFmpegPathButtonText()), PickFFmpegPathClicked)); _gui.Add(new GUIButton(new GUIContent(OutputFolderButtonText(), OutputFolderButtonText()), PickOutputFolderClicked)); _gui.Add(new GUIIntSlider(new GUIContent("Super Size", "Frames will be rendered at this multiple of the current resolution"), _recordVideo.superSize, 1, 4, SuperSizeChanged)); _gui.Add(new GUIIntSlider(new GUIContent("Framerate", "The fixed framerate of recorded video"), _recordVideo.captureFramerate, 10, 60, FramerateChanged)); _gui.Add(new GUIEnumPopup(new GUIContent("Output Format"), (OutputFormat)EditorPrefs.GetInt(OutputFormatPrefsKey), OutputFormatChanged)); GUIToggle deleteFrames = _gui.Add(new GUIToggle(new GUIContent("Delete Frames", "Delete all frames after compiling videos"), DeleteFramesChanged)) as GUIToggle; deleteFrames.isToggled = EditorPrefs.GetBool(DeleteFramesPrefsKey); _gui.Add(new GUISpace()); _gui.Add(new GUIEnumPopup(new GUIContent("Record Hotkey", "The key that will toggle recording during play mode"), (KeyCode)EditorPrefs.GetInt(RecordHotkeyPrefsKey), RecordHotkeyChanged)); _recordButton = _gui.Add(new GUIButton(new GUIContent("Record"), RecordClicked)) as GUIButton; _recordButton.isEnabled = EditorApplication.isPlaying; EditorApplication.playmodeStateChanged += PlayModeStateChanged; }
void OnEnable() { InitializedPrefsIfNeeded(); _recordVideo = FindOrCreateRecordVideo(); _gui = new GUIVertical(); _gui.Add( new GUIButton( new GUIContent( FFmpegPathButtonText(), FFmpegPathButtonText()), PickFFmpegPathClicked)); _gui.Add( new GUIButton( new GUIContent( OutputFolderButtonText(), OutputFolderButtonText()), PickOutputFolderClicked)); _gui.Add( new GUIIntSlider( new GUIContent( "Super Size", "Frames will be rendered at this multiple of the current resolution"), _recordVideo.superSize, 1, 4, SuperSizeChanged)); _gui.Add( new GUIIntSlider( new GUIContent( "Framerate", "The fixed framerate of recorded video"), _recordVideo.captureFramerate, 10, 60, FramerateChanged)); _gui.Add( new GUIEnumPopup( new GUIContent( "Output Format"), (OutputFormat) EditorPrefs.GetInt( OutputFormatPrefsKey), OutputFormatChanged)); GUIToggle deleteFrames = _gui.Add( new GUIToggle( new GUIContent( "Delete Frames", "Delete all frames after compiling videos"), DeleteFramesChanged)) as GUIToggle; deleteFrames.isToggled = EditorPrefs.GetBool( DeleteFramesPrefsKey); _gui.Add( new GUISpace()); _gui.Add( new GUIEnumPopup( new GUIContent( "Record Hotkey", "The key that will toggle recording during play mode"), (KeyCode) EditorPrefs.GetInt( RecordHotkeyPrefsKey), RecordHotkeyChanged)); _recordButton = _gui.Add( new GUIButton( new GUIContent( "Record"), RecordClicked)) as GUIButton; _recordButton.isEnabled = EditorApplication.isPlaying; EditorApplication.playmodeStateChanged += PlayModeStateChanged; }
void OnDisable() { _gui = null; _recordButton = null; _recordVideo = null; EditorApplication.playmodeStateChanged -= PlayModeStateChanged; }
void PlayModeStateChanged() { _recordVideo = FindOrCreateRecordVideo(); _recordVideo.StopRecording(); _recordButton.isEnabled = EditorApplication.isPlaying; UpdateRecordButtonText(); if (EditorApplication.isPlayingOrWillChangePlaymode == false && EditorApplication.isPlaying == false) { CompileVideos(); } }
RecordVideo FindOrCreateRecordVideo() { RecordVideo recordVideo = FindObjectOfType <RecordVideo>(); if (recordVideo == null) { GameObject gameObject = new GameObject("RecordVideo"); gameObject.hideFlags = HideFlags.HideAndDontSave; recordVideo = gameObject.AddComponent <RecordVideo>(); } recordVideo.folderPath = EditorPrefs.GetString(OutputFolderPrefsKey); recordVideo.superSize = EditorPrefs.GetInt(SuperSizePrefsKey); recordVideo.captureFramerate = EditorPrefs.GetInt(FrameratePrefsKey); return(recordVideo); }
void PlayModeStateChanged() { _recordVideo = FindOrCreateRecordVideo(); _recordVideo.StopRecording(); _recordButton.isEnabled = EditorApplication.isPlaying; UpdateRecordButtonText(); if( EditorApplication.isPlayingOrWillChangePlaymode == false && EditorApplication.isPlaying == false) { CompileVideos(); } }