editor_interface.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. /**************************************************************************/
  2. /* editor_interface.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "editor_interface.h"
  31. #include "editor/editor_command_palette.h"
  32. #include "editor/editor_feature_profile.h"
  33. #include "editor/editor_node.h"
  34. #include "editor/editor_paths.h"
  35. #include "editor/editor_resource_preview.h"
  36. #include "editor/editor_scale.h"
  37. #include "editor/editor_settings.h"
  38. #include "editor/editor_undo_redo_manager.h"
  39. #include "editor/filesystem_dock.h"
  40. #include "editor/gui/editor_run_bar.h"
  41. #include "editor/inspector_dock.h"
  42. #include "editor/plugins/node_3d_editor_plugin.h"
  43. #include "main/main.h"
  44. #include "scene/gui/box_container.h"
  45. #include "scene/gui/control.h"
  46. #include "scene/main/window.h"
  47. #include "scene/resources/theme.h"
  48. EditorInterface *EditorInterface::singleton = nullptr;
  49. void EditorInterface::restart_editor(bool p_save) {
  50. if (p_save) {
  51. EditorNode::get_singleton()->save_all_scenes();
  52. }
  53. EditorNode::get_singleton()->restart_editor();
  54. }
  55. // Editor tools.
  56. EditorCommandPalette *EditorInterface::get_command_palette() const {
  57. return EditorCommandPalette::get_singleton();
  58. }
  59. EditorFileSystem *EditorInterface::get_resource_file_system() const {
  60. return EditorFileSystem::get_singleton();
  61. }
  62. EditorPaths *EditorInterface::get_editor_paths() const {
  63. return EditorPaths::get_singleton();
  64. }
  65. EditorResourcePreview *EditorInterface::get_resource_previewer() const {
  66. return EditorResourcePreview::get_singleton();
  67. }
  68. EditorSelection *EditorInterface::get_selection() const {
  69. return EditorNode::get_singleton()->get_editor_selection();
  70. }
  71. Ref<EditorSettings> EditorInterface::get_editor_settings() const {
  72. return EditorSettings::get_singleton();
  73. }
  74. TypedArray<Texture2D> EditorInterface::_make_mesh_previews(const TypedArray<Mesh> &p_meshes, int p_preview_size) {
  75. Vector<Ref<Mesh>> meshes;
  76. for (int i = 0; i < p_meshes.size(); i++) {
  77. meshes.push_back(p_meshes[i]);
  78. }
  79. Vector<Ref<Texture2D>> textures = make_mesh_previews(meshes, nullptr, p_preview_size);
  80. TypedArray<Texture2D> ret;
  81. for (int i = 0; i < textures.size(); i++) {
  82. ret.push_back(textures[i]);
  83. }
  84. return ret;
  85. }
  86. Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size) {
  87. int size = p_preview_size;
  88. RID scenario = RS::get_singleton()->scenario_create();
  89. RID viewport = RS::get_singleton()->viewport_create();
  90. RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ALWAYS);
  91. RS::get_singleton()->viewport_set_scenario(viewport, scenario);
  92. RS::get_singleton()->viewport_set_size(viewport, size, size);
  93. RS::get_singleton()->viewport_set_transparent_background(viewport, true);
  94. RS::get_singleton()->viewport_set_active(viewport, true);
  95. RID viewport_texture = RS::get_singleton()->viewport_get_texture(viewport);
  96. RID camera = RS::get_singleton()->camera_create();
  97. RS::get_singleton()->viewport_attach_camera(viewport, camera);
  98. RID light = RS::get_singleton()->directional_light_create();
  99. RID light_instance = RS::get_singleton()->instance_create2(light, scenario);
  100. RID light2 = RS::get_singleton()->directional_light_create();
  101. RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
  102. RID light_instance2 = RS::get_singleton()->instance_create2(light2, scenario);
  103. EditorProgress ep("mlib", TTR("Creating Mesh Previews"), p_meshes.size());
  104. Vector<Ref<Texture2D>> textures;
  105. for (int i = 0; i < p_meshes.size(); i++) {
  106. Ref<Mesh> mesh = p_meshes[i];
  107. if (!mesh.is_valid()) {
  108. textures.push_back(Ref<Texture2D>());
  109. continue;
  110. }
  111. Transform3D mesh_xform;
  112. if (p_transforms != nullptr) {
  113. mesh_xform = (*p_transforms)[i];
  114. }
  115. RID inst = RS::get_singleton()->instance_create2(mesh->get_rid(), scenario);
  116. RS::get_singleton()->instance_set_transform(inst, mesh_xform);
  117. AABB aabb = mesh->get_aabb();
  118. Vector3 ofs = aabb.get_center();
  119. aabb.position -= ofs;
  120. Transform3D xform;
  121. xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI / 6);
  122. xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI / 6) * xform.basis;
  123. AABB rot_aabb = xform.xform(aabb);
  124. float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
  125. if (m == 0) {
  126. textures.push_back(Ref<Texture2D>());
  127. continue;
  128. }
  129. xform.origin = -xform.basis.xform(ofs); //-ofs*m;
  130. xform.origin.z -= rot_aabb.size.z * 2;
  131. xform.invert();
  132. xform = mesh_xform * xform;
  133. RS::get_singleton()->camera_set_transform(camera, xform * Transform3D(Basis(), Vector3(0, 0, 3)));
  134. RS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0);
  135. RS::get_singleton()->instance_set_transform(light_instance, xform * Transform3D().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0)));
  136. RS::get_singleton()->instance_set_transform(light_instance2, xform * Transform3D().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0)));
  137. ep.step(TTR("Thumbnail..."), i);
  138. DisplayServer::get_singleton()->process_events();
  139. Main::iteration();
  140. Main::iteration();
  141. Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture);
  142. ERR_CONTINUE(!img.is_valid() || img->is_empty());
  143. Ref<ImageTexture> it = ImageTexture::create_from_image(img);
  144. RS::get_singleton()->free(inst);
  145. textures.push_back(it);
  146. }
  147. RS::get_singleton()->free(viewport);
  148. RS::get_singleton()->free(light);
  149. RS::get_singleton()->free(light_instance);
  150. RS::get_singleton()->free(light2);
  151. RS::get_singleton()->free(light_instance2);
  152. RS::get_singleton()->free(camera);
  153. RS::get_singleton()->free(scenario);
  154. return textures;
  155. }
  156. void EditorInterface::set_plugin_enabled(const String &p_plugin, bool p_enabled) {
  157. EditorNode::get_singleton()->set_addon_plugin_enabled(p_plugin, p_enabled, true);
  158. }
  159. bool EditorInterface::is_plugin_enabled(const String &p_plugin) const {
  160. return EditorNode::get_singleton()->is_addon_plugin_enabled(p_plugin);
  161. }
  162. // Editor GUI.
  163. Ref<Theme> EditorInterface::get_editor_theme() const {
  164. return EditorNode::get_singleton()->get_editor_theme();
  165. }
  166. Control *EditorInterface::get_base_control() const {
  167. return EditorNode::get_singleton()->get_gui_base();
  168. }
  169. VBoxContainer *EditorInterface::get_editor_main_screen() const {
  170. return EditorNode::get_singleton()->get_main_screen_control();
  171. }
  172. ScriptEditor *EditorInterface::get_script_editor() const {
  173. return ScriptEditor::get_singleton();
  174. }
  175. SubViewport *EditorInterface::get_editor_viewport_2d() const {
  176. return EditorNode::get_singleton()->get_scene_root();
  177. }
  178. SubViewport *EditorInterface::get_editor_viewport_3d(int p_idx) const {
  179. ERR_FAIL_INDEX_V(p_idx, static_cast<int>(Node3DEditor::VIEWPORTS_COUNT), nullptr);
  180. return Node3DEditor::get_singleton()->get_editor_viewport(p_idx)->get_viewport_node();
  181. }
  182. void EditorInterface::set_main_screen_editor(const String &p_name) {
  183. EditorNode::get_singleton()->select_editor_by_name(p_name);
  184. }
  185. void EditorInterface::set_distraction_free_mode(bool p_enter) {
  186. EditorNode::get_singleton()->set_distraction_free_mode(p_enter);
  187. }
  188. bool EditorInterface::is_distraction_free_mode_enabled() const {
  189. return EditorNode::get_singleton()->is_distraction_free_mode_enabled();
  190. }
  191. float EditorInterface::get_editor_scale() const {
  192. return EDSCALE;
  193. }
  194. void EditorInterface::popup_dialog(Window *p_dialog, const Rect2i &p_screen_rect) {
  195. p_dialog->popup_exclusive(EditorNode::get_singleton(), p_screen_rect);
  196. }
  197. void EditorInterface::popup_dialog_centered(Window *p_dialog, const Size2i &p_minsize) {
  198. p_dialog->popup_exclusive_centered(EditorNode::get_singleton(), p_minsize);
  199. }
  200. void EditorInterface::popup_dialog_centered_ratio(Window *p_dialog, float p_ratio) {
  201. p_dialog->popup_exclusive_centered_ratio(EditorNode::get_singleton(), p_ratio);
  202. }
  203. void EditorInterface::popup_dialog_centered_clamped(Window *p_dialog, const Size2i &p_size, float p_fallback_ratio) {
  204. p_dialog->popup_exclusive_centered_clamped(EditorNode::get_singleton(), p_size, p_fallback_ratio);
  205. }
  206. String EditorInterface::get_current_feature_profile() const {
  207. return EditorFeatureProfileManager::get_singleton()->get_current_profile_name();
  208. }
  209. void EditorInterface::set_current_feature_profile(const String &p_profile_name) {
  210. EditorFeatureProfileManager::get_singleton()->set_current_profile(p_profile_name, true);
  211. }
  212. // Editor docks.
  213. FileSystemDock *EditorInterface::get_file_system_dock() const {
  214. return FileSystemDock::get_singleton();
  215. }
  216. void EditorInterface::select_file(const String &p_file) {
  217. FileSystemDock::get_singleton()->select_file(p_file);
  218. }
  219. Vector<String> EditorInterface::get_selected_paths() const {
  220. return FileSystemDock::get_singleton()->get_selected_paths();
  221. }
  222. String EditorInterface::get_current_path() const {
  223. return FileSystemDock::get_singleton()->get_current_path();
  224. }
  225. String EditorInterface::get_current_directory() const {
  226. return FileSystemDock::get_singleton()->get_current_directory();
  227. }
  228. EditorInspector *EditorInterface::get_inspector() const {
  229. return InspectorDock::get_inspector_singleton();
  230. }
  231. // Object/Resource/Node editing.
  232. void EditorInterface::inspect_object(Object *p_obj, const String &p_for_property, bool p_inspector_only) {
  233. EditorNode::get_singleton()->push_item(p_obj, p_for_property, p_inspector_only);
  234. }
  235. void EditorInterface::edit_resource(const Ref<Resource> &p_resource) {
  236. EditorNode::get_singleton()->edit_resource(p_resource);
  237. }
  238. void EditorInterface::edit_node(Node *p_node) {
  239. EditorNode::get_singleton()->edit_node(p_node);
  240. }
  241. void EditorInterface::edit_script(const Ref<Script> &p_script, int p_line, int p_col, bool p_grab_focus) {
  242. ScriptEditor::get_singleton()->edit(p_script, p_line - 1, p_col - 1, p_grab_focus);
  243. }
  244. void EditorInterface::open_scene_from_path(const String &scene_path) {
  245. if (EditorNode::get_singleton()->is_changing_scene()) {
  246. return;
  247. }
  248. EditorNode::get_singleton()->open_request(scene_path);
  249. }
  250. void EditorInterface::reload_scene_from_path(const String &scene_path) {
  251. if (EditorNode::get_singleton()->is_changing_scene()) {
  252. return;
  253. }
  254. EditorNode::get_singleton()->reload_scene(scene_path);
  255. }
  256. Node *EditorInterface::get_edited_scene_root() const {
  257. return EditorNode::get_singleton()->get_edited_scene();
  258. }
  259. PackedStringArray EditorInterface::get_open_scenes() const {
  260. PackedStringArray ret;
  261. Vector<EditorData::EditedScene> scenes = EditorNode::get_editor_data().get_edited_scenes();
  262. int scns_amount = scenes.size();
  263. for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) {
  264. if (scenes[idx_scn].root == nullptr) {
  265. continue;
  266. }
  267. ret.push_back(scenes[idx_scn].root->get_scene_file_path());
  268. }
  269. return ret;
  270. }
  271. Error EditorInterface::save_scene() {
  272. if (!get_edited_scene_root()) {
  273. return ERR_CANT_CREATE;
  274. }
  275. if (get_edited_scene_root()->get_scene_file_path().is_empty()) {
  276. return ERR_CANT_CREATE;
  277. }
  278. save_scene_as(get_edited_scene_root()->get_scene_file_path());
  279. return OK;
  280. }
  281. void EditorInterface::save_scene_as(const String &p_scene, bool p_with_preview) {
  282. EditorNode::get_singleton()->save_scene_to_path(p_scene, p_with_preview);
  283. }
  284. void EditorInterface::mark_scene_as_unsaved() {
  285. EditorUndoRedoManager::get_singleton()->set_history_as_unsaved(EditorNode::get_editor_data().get_current_edited_scene_history_id());
  286. }
  287. void EditorInterface::save_all_scenes() {
  288. EditorNode::get_singleton()->save_all_scenes();
  289. }
  290. // Scene playback.
  291. void EditorInterface::play_main_scene() {
  292. EditorRunBar::get_singleton()->play_main_scene();
  293. }
  294. void EditorInterface::play_current_scene() {
  295. EditorRunBar::get_singleton()->play_current_scene();
  296. }
  297. void EditorInterface::play_custom_scene(const String &scene_path) {
  298. EditorRunBar::get_singleton()->play_custom_scene(scene_path);
  299. }
  300. void EditorInterface::stop_playing_scene() {
  301. EditorRunBar::get_singleton()->stop_playing();
  302. }
  303. bool EditorInterface::is_playing_scene() const {
  304. return EditorRunBar::get_singleton()->is_playing();
  305. }
  306. String EditorInterface::get_playing_scene() const {
  307. return EditorRunBar::get_singleton()->get_playing_scene();
  308. }
  309. void EditorInterface::set_movie_maker_enabled(bool p_enabled) {
  310. EditorRunBar::get_singleton()->set_movie_maker_enabled(p_enabled);
  311. }
  312. bool EditorInterface::is_movie_maker_enabled() const {
  313. return EditorRunBar::get_singleton()->is_movie_maker_enabled();
  314. }
  315. // Base.
  316. void EditorInterface::_bind_methods() {
  317. ClassDB::bind_method(D_METHOD("restart_editor", "save"), &EditorInterface::restart_editor, DEFVAL(true));
  318. // Editor tools.
  319. ClassDB::bind_method(D_METHOD("get_command_palette"), &EditorInterface::get_command_palette);
  320. ClassDB::bind_method(D_METHOD("get_resource_filesystem"), &EditorInterface::get_resource_file_system);
  321. ClassDB::bind_method(D_METHOD("get_editor_paths"), &EditorInterface::get_editor_paths);
  322. ClassDB::bind_method(D_METHOD("get_resource_previewer"), &EditorInterface::get_resource_previewer);
  323. ClassDB::bind_method(D_METHOD("get_selection"), &EditorInterface::get_selection);
  324. ClassDB::bind_method(D_METHOD("get_editor_settings"), &EditorInterface::get_editor_settings);
  325. ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews);
  326. ClassDB::bind_method(D_METHOD("set_plugin_enabled", "plugin", "enabled"), &EditorInterface::set_plugin_enabled);
  327. ClassDB::bind_method(D_METHOD("is_plugin_enabled", "plugin"), &EditorInterface::is_plugin_enabled);
  328. // Editor GUI.
  329. ClassDB::bind_method(D_METHOD("get_editor_theme"), &EditorInterface::get_editor_theme);
  330. ClassDB::bind_method(D_METHOD("get_base_control"), &EditorInterface::get_base_control);
  331. ClassDB::bind_method(D_METHOD("get_editor_main_screen"), &EditorInterface::get_editor_main_screen);
  332. ClassDB::bind_method(D_METHOD("get_script_editor"), &EditorInterface::get_script_editor);
  333. ClassDB::bind_method(D_METHOD("get_editor_viewport_2d"), &EditorInterface::get_editor_viewport_2d);
  334. ClassDB::bind_method(D_METHOD("get_editor_viewport_3d", "idx"), &EditorInterface::get_editor_viewport_3d, DEFVAL(0));
  335. ClassDB::bind_method(D_METHOD("set_main_screen_editor", "name"), &EditorInterface::set_main_screen_editor);
  336. ClassDB::bind_method(D_METHOD("set_distraction_free_mode", "enter"), &EditorInterface::set_distraction_free_mode);
  337. ClassDB::bind_method(D_METHOD("is_distraction_free_mode_enabled"), &EditorInterface::is_distraction_free_mode_enabled);
  338. ClassDB::bind_method(D_METHOD("get_editor_scale"), &EditorInterface::get_editor_scale);
  339. ClassDB::bind_method(D_METHOD("popup_dialog", "dialog", "rect"), &EditorInterface::popup_dialog, DEFVAL(Rect2i()));
  340. ClassDB::bind_method(D_METHOD("popup_dialog_centered", "dialog", "minsize"), &EditorInterface::popup_dialog_centered, DEFVAL(Size2i()));
  341. ClassDB::bind_method(D_METHOD("popup_dialog_centered_ratio", "dialog", "ratio"), &EditorInterface::popup_dialog_centered_ratio, DEFVAL(0.8));
  342. ClassDB::bind_method(D_METHOD("popup_dialog_centered_clamped", "dialog", "minsize", "fallback_ratio"), &EditorInterface::popup_dialog_centered_clamped, DEFVAL(Size2i()), DEFVAL(0.75));
  343. ClassDB::bind_method(D_METHOD("get_current_feature_profile"), &EditorInterface::get_current_feature_profile);
  344. ClassDB::bind_method(D_METHOD("set_current_feature_profile", "profile_name"), &EditorInterface::set_current_feature_profile);
  345. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "distraction_free_mode"), "set_distraction_free_mode", "is_distraction_free_mode_enabled");
  346. // Editor docks.
  347. ClassDB::bind_method(D_METHOD("get_file_system_dock"), &EditorInterface::get_file_system_dock);
  348. ClassDB::bind_method(D_METHOD("select_file", "file"), &EditorInterface::select_file);
  349. ClassDB::bind_method(D_METHOD("get_selected_paths"), &EditorInterface::get_selected_paths);
  350. ClassDB::bind_method(D_METHOD("get_current_path"), &EditorInterface::get_current_path);
  351. ClassDB::bind_method(D_METHOD("get_current_directory"), &EditorInterface::get_current_directory);
  352. ClassDB::bind_method(D_METHOD("get_inspector"), &EditorInterface::get_inspector);
  353. // Object/Resource/Node editing.
  354. ClassDB::bind_method(D_METHOD("inspect_object", "object", "for_property", "inspector_only"), &EditorInterface::inspect_object, DEFVAL(String()), DEFVAL(false));
  355. ClassDB::bind_method(D_METHOD("edit_resource", "resource"), &EditorInterface::edit_resource);
  356. ClassDB::bind_method(D_METHOD("edit_node", "node"), &EditorInterface::edit_node);
  357. ClassDB::bind_method(D_METHOD("edit_script", "script", "line", "column", "grab_focus"), &EditorInterface::edit_script, DEFVAL(-1), DEFVAL(0), DEFVAL(true));
  358. ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorInterface::open_scene_from_path);
  359. ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorInterface::reload_scene_from_path);
  360. ClassDB::bind_method(D_METHOD("get_open_scenes"), &EditorInterface::get_open_scenes);
  361. ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &EditorInterface::get_edited_scene_root);
  362. ClassDB::bind_method(D_METHOD("save_scene"), &EditorInterface::save_scene);
  363. ClassDB::bind_method(D_METHOD("save_scene_as", "path", "with_preview"), &EditorInterface::save_scene_as, DEFVAL(true));
  364. ClassDB::bind_method(D_METHOD("save_all_scenes"), &EditorInterface::save_all_scenes);
  365. ClassDB::bind_method(D_METHOD("mark_scene_as_unsaved"), &EditorInterface::mark_scene_as_unsaved);
  366. // Scene playback.
  367. ClassDB::bind_method(D_METHOD("play_main_scene"), &EditorInterface::play_main_scene);
  368. ClassDB::bind_method(D_METHOD("play_current_scene"), &EditorInterface::play_current_scene);
  369. ClassDB::bind_method(D_METHOD("play_custom_scene", "scene_filepath"), &EditorInterface::play_custom_scene);
  370. ClassDB::bind_method(D_METHOD("stop_playing_scene"), &EditorInterface::stop_playing_scene);
  371. ClassDB::bind_method(D_METHOD("is_playing_scene"), &EditorInterface::is_playing_scene);
  372. ClassDB::bind_method(D_METHOD("get_playing_scene"), &EditorInterface::get_playing_scene);
  373. ClassDB::bind_method(D_METHOD("set_movie_maker_enabled", "enabled"), &EditorInterface::set_movie_maker_enabled);
  374. ClassDB::bind_method(D_METHOD("is_movie_maker_enabled"), &EditorInterface::is_movie_maker_enabled);
  375. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "movie_maker_enabled"), "set_movie_maker_enabled", "is_movie_maker_enabled");
  376. }
  377. void EditorInterface::create() {
  378. memnew(EditorInterface);
  379. }
  380. void EditorInterface::free() {
  381. ERR_FAIL_NULL(singleton);
  382. memdelete(singleton);
  383. }
  384. EditorInterface::EditorInterface() {
  385. ERR_FAIL_COND(singleton != nullptr);
  386. singleton = this;
  387. }