diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-22 21:44:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-22 21:44:50 +0200 |
commit | 85cb22bd919290be8ad6349edc34e5d39102f244 (patch) | |
tree | 794635dd09c926d6d5bada7852518dcb5993bf02 | |
parent | 1f61d477662fdbbb43cd3703aaac2d25d1c19e3a (diff) | |
parent | 92f5a0a1db8a4629c9ecebfd4c0943b5086d832c (diff) |
Merge pull request #64593 from aaronfranke/editor-restart
-rw-r--r-- | doc/classes/EditorInterface.xml | 7 | ||||
-rw-r--r-- | editor/editor_plugin.cpp | 8 | ||||
-rw-r--r-- | editor/editor_plugin.h | 1 |
3 files changed, 16 insertions, 0 deletions
diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml index 1dd53e1394..beed364974 100644 --- a/doc/classes/EditorInterface.xml +++ b/doc/classes/EditorInterface.xml @@ -206,6 +206,13 @@ Reloads the scene at the given path. </description> </method> + <method name="restart_editor"> + <return type="void" /> + <param index="0" name="save" type="bool" default="true" /> + <description> + Restarts the editor. This closes the editor and then opens the same project. If [param save] is [code]true[/code], the project will be saved before restarting. + </description> + </method> <method name="save_scene"> <return type="int" enum="Error" /> <description> diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 400ad1ebac..d43eb9375a 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -312,6 +312,13 @@ void EditorInterface::set_distraction_free_mode(bool p_enter) { EditorNode::get_singleton()->set_distraction_free_mode(p_enter); } +void EditorInterface::restart_editor(bool p_save) { + if (p_save) { + EditorNode::get_singleton()->save_all_scenes(); + } + EditorNode::get_singleton()->restart_editor(); +} + bool EditorInterface::is_distraction_free_mode_enabled() const { return EditorNode::get_singleton()->is_distraction_free_mode_enabled(); } @@ -360,6 +367,7 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("save_scene"), &EditorInterface::save_scene); ClassDB::bind_method(D_METHOD("save_scene_as", "path", "with_preview"), &EditorInterface::save_scene_as, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("restart_editor", "save"), &EditorInterface::restart_editor, DEFVAL(true)); ClassDB::bind_method(D_METHOD("set_main_screen_editor", "name"), &EditorInterface::set_main_screen_editor); ClassDB::bind_method(D_METHOD("set_distraction_free_mode", "enter"), &EditorInterface::set_distraction_free_mode); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 3f9d276b6a..d20d96051b 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -116,6 +116,7 @@ public: Error save_scene(); void save_scene_as(const String &p_scene, bool p_with_preview = true); + void restart_editor(bool p_save = true); Vector<Ref<Texture2D>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size); |