editor_plugin.cpp 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  1. /**************************************************************************/
  2. /* editor_plugin.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_plugin.h"
  31. #include "editor/debugger/editor_debugger_node.h"
  32. #include "editor/editor_command_palette.h"
  33. #include "editor/editor_node.h"
  34. #include "editor/editor_paths.h"
  35. #include "editor/editor_resource_preview.h"
  36. #include "editor/editor_settings.h"
  37. #include "editor/editor_translation_parser.h"
  38. #include "editor/editor_undo_redo_manager.h"
  39. #include "editor/export/editor_export.h"
  40. #include "editor/filesystem_dock.h"
  41. #include "editor/import/editor_import_plugin.h"
  42. #include "editor/import/resource_importer_scene.h"
  43. #include "editor/inspector_dock.h"
  44. #include "editor/plugins/canvas_item_editor_plugin.h"
  45. #include "editor/plugins/editor_debugger_plugin.h"
  46. #include "editor/plugins/editor_resource_conversion_plugin.h"
  47. #include "editor/plugins/node_3d_editor_plugin.h"
  48. #include "editor/plugins/script_editor_plugin.h"
  49. #include "editor/project_settings_editor.h"
  50. #include "editor/scene_tree_dock.h"
  51. #include "main/main.h"
  52. #include "scene/3d/camera_3d.h"
  53. #include "scene/gui/popup_menu.h"
  54. #include "servers/rendering_server.h"
  55. TypedArray<Texture2D> EditorInterface::_make_mesh_previews(const TypedArray<Mesh> &p_meshes, int p_preview_size) {
  56. Vector<Ref<Mesh>> meshes;
  57. for (int i = 0; i < p_meshes.size(); i++) {
  58. meshes.push_back(p_meshes[i]);
  59. }
  60. Vector<Ref<Texture2D>> textures = make_mesh_previews(meshes, nullptr, p_preview_size);
  61. TypedArray<Texture2D> ret;
  62. for (int i = 0; i < textures.size(); i++) {
  63. ret.push_back(textures[i]);
  64. }
  65. return ret;
  66. }
  67. Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size) {
  68. int size = p_preview_size;
  69. RID scenario = RS::get_singleton()->scenario_create();
  70. RID viewport = RS::get_singleton()->viewport_create();
  71. RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ALWAYS);
  72. RS::get_singleton()->viewport_set_scenario(viewport, scenario);
  73. RS::get_singleton()->viewport_set_size(viewport, size, size);
  74. RS::get_singleton()->viewport_set_transparent_background(viewport, true);
  75. RS::get_singleton()->viewport_set_active(viewport, true);
  76. RID viewport_texture = RS::get_singleton()->viewport_get_texture(viewport);
  77. RID camera = RS::get_singleton()->camera_create();
  78. RS::get_singleton()->viewport_attach_camera(viewport, camera);
  79. RID light = RS::get_singleton()->directional_light_create();
  80. RID light_instance = RS::get_singleton()->instance_create2(light, scenario);
  81. RID light2 = RS::get_singleton()->directional_light_create();
  82. RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
  83. RID light_instance2 = RS::get_singleton()->instance_create2(light2, scenario);
  84. EditorProgress ep("mlib", TTR("Creating Mesh Previews"), p_meshes.size());
  85. Vector<Ref<Texture2D>> textures;
  86. for (int i = 0; i < p_meshes.size(); i++) {
  87. Ref<Mesh> mesh = p_meshes[i];
  88. if (!mesh.is_valid()) {
  89. textures.push_back(Ref<Texture2D>());
  90. continue;
  91. }
  92. Transform3D mesh_xform;
  93. if (p_transforms != nullptr) {
  94. mesh_xform = (*p_transforms)[i];
  95. }
  96. RID inst = RS::get_singleton()->instance_create2(mesh->get_rid(), scenario);
  97. RS::get_singleton()->instance_set_transform(inst, mesh_xform);
  98. AABB aabb = mesh->get_aabb();
  99. Vector3 ofs = aabb.get_center();
  100. aabb.position -= ofs;
  101. Transform3D xform;
  102. xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI / 6);
  103. xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI / 6) * xform.basis;
  104. AABB rot_aabb = xform.xform(aabb);
  105. float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
  106. if (m == 0) {
  107. textures.push_back(Ref<Texture2D>());
  108. continue;
  109. }
  110. xform.origin = -xform.basis.xform(ofs); //-ofs*m;
  111. xform.origin.z -= rot_aabb.size.z * 2;
  112. xform.invert();
  113. xform = mesh_xform * xform;
  114. RS::get_singleton()->camera_set_transform(camera, xform * Transform3D(Basis(), Vector3(0, 0, 3)));
  115. RS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0);
  116. RS::get_singleton()->instance_set_transform(light_instance, xform * Transform3D().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0)));
  117. RS::get_singleton()->instance_set_transform(light_instance2, xform * Transform3D().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0)));
  118. ep.step(TTR("Thumbnail..."), i);
  119. DisplayServer::get_singleton()->process_events();
  120. Main::iteration();
  121. Main::iteration();
  122. Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture);
  123. ERR_CONTINUE(!img.is_valid() || img->is_empty());
  124. Ref<ImageTexture> it = ImageTexture::create_from_image(img);
  125. RS::get_singleton()->free(inst);
  126. textures.push_back(it);
  127. }
  128. RS::get_singleton()->free(viewport);
  129. RS::get_singleton()->free(light);
  130. RS::get_singleton()->free(light_instance);
  131. RS::get_singleton()->free(light2);
  132. RS::get_singleton()->free(light_instance2);
  133. RS::get_singleton()->free(camera);
  134. RS::get_singleton()->free(scenario);
  135. return textures;
  136. }
  137. void EditorInterface::set_main_screen_editor(const String &p_name) {
  138. EditorNode::get_singleton()->select_editor_by_name(p_name);
  139. }
  140. VBoxContainer *EditorInterface::get_editor_main_screen() {
  141. return EditorNode::get_singleton()->get_main_screen_control();
  142. }
  143. void EditorInterface::edit_resource(const Ref<Resource> &p_resource) {
  144. EditorNode::get_singleton()->edit_resource(p_resource);
  145. }
  146. void EditorInterface::edit_node(Node *p_node) {
  147. EditorNode::get_singleton()->edit_node(p_node);
  148. }
  149. void EditorInterface::edit_script(const Ref<Script> &p_script, int p_line, int p_col, bool p_grab_focus) {
  150. ScriptEditor::get_singleton()->edit(p_script, p_line, p_col, p_grab_focus);
  151. }
  152. void EditorInterface::open_scene_from_path(const String &scene_path) {
  153. if (EditorNode::get_singleton()->is_changing_scene()) {
  154. return;
  155. }
  156. EditorNode::get_singleton()->open_request(scene_path);
  157. }
  158. void EditorInterface::reload_scene_from_path(const String &scene_path) {
  159. if (EditorNode::get_singleton()->is_changing_scene()) {
  160. return;
  161. }
  162. EditorNode::get_singleton()->reload_scene(scene_path);
  163. }
  164. void EditorInterface::play_main_scene() {
  165. EditorNode::get_singleton()->run_play();
  166. }
  167. void EditorInterface::play_current_scene() {
  168. EditorNode::get_singleton()->run_play_current();
  169. }
  170. void EditorInterface::play_custom_scene(const String &scene_path) {
  171. EditorNode::get_singleton()->run_play_custom(scene_path);
  172. }
  173. void EditorInterface::stop_playing_scene() {
  174. EditorNode::get_singleton()->run_stop();
  175. }
  176. bool EditorInterface::is_playing_scene() const {
  177. return EditorNode::get_singleton()->is_run_playing();
  178. }
  179. String EditorInterface::get_playing_scene() const {
  180. return EditorNode::get_singleton()->get_run_playing_scene();
  181. }
  182. Node *EditorInterface::get_edited_scene_root() {
  183. return EditorNode::get_singleton()->get_edited_scene();
  184. }
  185. PackedStringArray EditorInterface::get_open_scenes() const {
  186. PackedStringArray ret;
  187. Vector<EditorData::EditedScene> scenes = EditorNode::get_editor_data().get_edited_scenes();
  188. int scns_amount = scenes.size();
  189. for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) {
  190. if (scenes[idx_scn].root == nullptr) {
  191. continue;
  192. }
  193. ret.push_back(scenes[idx_scn].root->get_scene_file_path());
  194. }
  195. return ret;
  196. }
  197. ScriptEditor *EditorInterface::get_script_editor() {
  198. return ScriptEditor::get_singleton();
  199. }
  200. void EditorInterface::select_file(const String &p_file) {
  201. FileSystemDock::get_singleton()->select_file(p_file);
  202. }
  203. Vector<String> EditorInterface::get_selected_paths() const {
  204. return FileSystemDock::get_singleton()->get_selected_paths();
  205. }
  206. String EditorInterface::get_current_path() const {
  207. return FileSystemDock::get_singleton()->get_current_path();
  208. }
  209. String EditorInterface::get_current_directory() const {
  210. return FileSystemDock::get_singleton()->get_current_directory();
  211. }
  212. void EditorInterface::inspect_object(Object *p_obj, const String &p_for_property, bool p_inspector_only) {
  213. EditorNode::get_singleton()->push_item(p_obj, p_for_property, p_inspector_only);
  214. }
  215. EditorFileSystem *EditorInterface::get_resource_file_system() {
  216. return EditorFileSystem::get_singleton();
  217. }
  218. FileSystemDock *EditorInterface::get_file_system_dock() {
  219. return FileSystemDock::get_singleton();
  220. }
  221. EditorSelection *EditorInterface::get_selection() {
  222. return EditorNode::get_singleton()->get_editor_selection();
  223. }
  224. Ref<EditorSettings> EditorInterface::get_editor_settings() {
  225. return EditorSettings::get_singleton();
  226. }
  227. EditorPaths *EditorInterface::get_editor_paths() {
  228. return EditorPaths::get_singleton();
  229. }
  230. EditorResourcePreview *EditorInterface::get_resource_previewer() {
  231. return EditorResourcePreview::get_singleton();
  232. }
  233. Control *EditorInterface::get_base_control() {
  234. return EditorNode::get_singleton()->get_gui_base();
  235. }
  236. float EditorInterface::get_editor_scale() const {
  237. return EDSCALE;
  238. }
  239. void EditorInterface::set_plugin_enabled(const String &p_plugin, bool p_enabled) {
  240. EditorNode::get_singleton()->set_addon_plugin_enabled(p_plugin, p_enabled, true);
  241. }
  242. bool EditorInterface::is_plugin_enabled(const String &p_plugin) const {
  243. return EditorNode::get_singleton()->is_addon_plugin_enabled(p_plugin);
  244. }
  245. void EditorInterface::set_movie_maker_enabled(bool p_enabled) {
  246. EditorNode::get_singleton()->set_movie_maker_enabled(p_enabled);
  247. }
  248. bool EditorInterface::is_movie_maker_enabled() const {
  249. return EditorNode::get_singleton()->is_movie_maker_enabled();
  250. }
  251. EditorInspector *EditorInterface::get_inspector() const {
  252. return InspectorDock::get_inspector_singleton();
  253. }
  254. Error EditorInterface::save_scene() {
  255. if (!get_edited_scene_root()) {
  256. return ERR_CANT_CREATE;
  257. }
  258. if (get_edited_scene_root()->get_scene_file_path().is_empty()) {
  259. return ERR_CANT_CREATE;
  260. }
  261. save_scene_as(get_edited_scene_root()->get_scene_file_path());
  262. return OK;
  263. }
  264. void EditorInterface::save_scene_as(const String &p_scene, bool p_with_preview) {
  265. EditorNode::get_singleton()->save_scene_to_path(p_scene, p_with_preview);
  266. }
  267. void EditorInterface::set_distraction_free_mode(bool p_enter) {
  268. EditorNode::get_singleton()->set_distraction_free_mode(p_enter);
  269. }
  270. void EditorInterface::restart_editor(bool p_save) {
  271. if (p_save) {
  272. EditorNode::get_singleton()->save_all_scenes();
  273. }
  274. EditorNode::get_singleton()->restart_editor();
  275. }
  276. bool EditorInterface::is_distraction_free_mode_enabled() const {
  277. return EditorNode::get_singleton()->is_distraction_free_mode_enabled();
  278. }
  279. EditorCommandPalette *EditorInterface::get_command_palette() const {
  280. return EditorCommandPalette::get_singleton();
  281. }
  282. EditorInterface *EditorInterface::singleton = nullptr;
  283. void EditorInterface::_bind_methods() {
  284. ClassDB::bind_method(D_METHOD("inspect_object", "object", "for_property", "inspector_only"), &EditorInterface::inspect_object, DEFVAL(String()), DEFVAL(false));
  285. ClassDB::bind_method(D_METHOD("get_selection"), &EditorInterface::get_selection);
  286. ClassDB::bind_method(D_METHOD("get_editor_settings"), &EditorInterface::get_editor_settings);
  287. ClassDB::bind_method(D_METHOD("get_script_editor"), &EditorInterface::get_script_editor);
  288. ClassDB::bind_method(D_METHOD("get_base_control"), &EditorInterface::get_base_control);
  289. ClassDB::bind_method(D_METHOD("get_editor_scale"), &EditorInterface::get_editor_scale);
  290. ClassDB::bind_method(D_METHOD("edit_resource", "resource"), &EditorInterface::edit_resource);
  291. ClassDB::bind_method(D_METHOD("edit_node", "node"), &EditorInterface::edit_node);
  292. ClassDB::bind_method(D_METHOD("edit_script", "script", "line", "column", "grab_focus"), &EditorInterface::edit_script, DEFVAL(-1), DEFVAL(0), DEFVAL(true));
  293. ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorInterface::open_scene_from_path);
  294. ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorInterface::reload_scene_from_path);
  295. ClassDB::bind_method(D_METHOD("play_main_scene"), &EditorInterface::play_main_scene);
  296. ClassDB::bind_method(D_METHOD("play_current_scene"), &EditorInterface::play_current_scene);
  297. ClassDB::bind_method(D_METHOD("play_custom_scene", "scene_filepath"), &EditorInterface::play_custom_scene);
  298. ClassDB::bind_method(D_METHOD("stop_playing_scene"), &EditorInterface::stop_playing_scene);
  299. ClassDB::bind_method(D_METHOD("is_playing_scene"), &EditorInterface::is_playing_scene);
  300. ClassDB::bind_method(D_METHOD("get_playing_scene"), &EditorInterface::get_playing_scene);
  301. ClassDB::bind_method(D_METHOD("get_open_scenes"), &EditorInterface::get_open_scenes);
  302. ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &EditorInterface::get_edited_scene_root);
  303. ClassDB::bind_method(D_METHOD("get_resource_previewer"), &EditorInterface::get_resource_previewer);
  304. ClassDB::bind_method(D_METHOD("get_resource_filesystem"), &EditorInterface::get_resource_file_system);
  305. ClassDB::bind_method(D_METHOD("get_editor_main_screen"), &EditorInterface::get_editor_main_screen);
  306. ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews);
  307. ClassDB::bind_method(D_METHOD("select_file", "file"), &EditorInterface::select_file);
  308. ClassDB::bind_method(D_METHOD("get_selected_paths"), &EditorInterface::get_selected_paths);
  309. ClassDB::bind_method(D_METHOD("get_current_path"), &EditorInterface::get_current_path);
  310. ClassDB::bind_method(D_METHOD("get_current_directory"), &EditorInterface::get_current_directory);
  311. ClassDB::bind_method(D_METHOD("get_file_system_dock"), &EditorInterface::get_file_system_dock);
  312. ClassDB::bind_method(D_METHOD("get_editor_paths"), &EditorInterface::get_editor_paths);
  313. ClassDB::bind_method(D_METHOD("get_command_palette"), &EditorInterface::get_command_palette);
  314. ClassDB::bind_method(D_METHOD("set_plugin_enabled", "plugin", "enabled"), &EditorInterface::set_plugin_enabled);
  315. ClassDB::bind_method(D_METHOD("is_plugin_enabled", "plugin"), &EditorInterface::is_plugin_enabled);
  316. ClassDB::bind_method(D_METHOD("set_movie_maker_enabled", "enabled"), &EditorInterface::set_movie_maker_enabled);
  317. ClassDB::bind_method(D_METHOD("is_movie_maker_enabled"), &EditorInterface::is_movie_maker_enabled);
  318. ClassDB::bind_method(D_METHOD("get_inspector"), &EditorInterface::get_inspector);
  319. ClassDB::bind_method(D_METHOD("save_scene"), &EditorInterface::save_scene);
  320. ClassDB::bind_method(D_METHOD("save_scene_as", "path", "with_preview"), &EditorInterface::save_scene_as, DEFVAL(true));
  321. ClassDB::bind_method(D_METHOD("restart_editor", "save"), &EditorInterface::restart_editor, DEFVAL(true));
  322. ClassDB::bind_method(D_METHOD("set_main_screen_editor", "name"), &EditorInterface::set_main_screen_editor);
  323. ClassDB::bind_method(D_METHOD("set_distraction_free_mode", "enter"), &EditorInterface::set_distraction_free_mode);
  324. ClassDB::bind_method(D_METHOD("is_distraction_free_mode_enabled"), &EditorInterface::is_distraction_free_mode_enabled);
  325. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "distraction_free_mode"), "set_distraction_free_mode", "is_distraction_free_mode_enabled");
  326. }
  327. EditorInterface::EditorInterface() {
  328. singleton = this;
  329. }
  330. ///////////////////////////////////////////
  331. void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) {
  332. EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon);
  333. }
  334. void EditorPlugin::remove_custom_type(const String &p_type) {
  335. EditorNode::get_editor_data().remove_custom_type(p_type);
  336. }
  337. void EditorPlugin::add_autoload_singleton(const String &p_name, const String &p_path) {
  338. EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_add(p_name, p_path);
  339. }
  340. void EditorPlugin::remove_autoload_singleton(const String &p_name) {
  341. EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_remove(p_name);
  342. }
  343. Button *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) {
  344. ERR_FAIL_NULL_V(p_control, nullptr);
  345. return EditorNode::get_singleton()->add_bottom_panel_item(p_title, p_control);
  346. }
  347. void EditorPlugin::add_control_to_dock(DockSlot p_slot, Control *p_control) {
  348. ERR_FAIL_NULL(p_control);
  349. EditorNode::get_singleton()->add_control_to_dock(EditorNode::DockSlot(p_slot), p_control);
  350. }
  351. void EditorPlugin::remove_control_from_docks(Control *p_control) {
  352. ERR_FAIL_NULL(p_control);
  353. EditorNode::get_singleton()->remove_control_from_dock(p_control);
  354. }
  355. void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
  356. ERR_FAIL_NULL(p_control);
  357. EditorNode::get_singleton()->remove_bottom_panel_item(p_control);
  358. }
  359. void EditorPlugin::add_control_to_container(CustomControlContainer p_location, Control *p_control) {
  360. ERR_FAIL_NULL(p_control);
  361. switch (p_location) {
  362. case CONTAINER_TOOLBAR: {
  363. EditorNode::get_menu_hb()->add_child(p_control);
  364. } break;
  365. case CONTAINER_SPATIAL_EDITOR_MENU: {
  366. Node3DEditor::get_singleton()->add_control_to_menu_panel(p_control);
  367. } break;
  368. case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: {
  369. Node3DEditor::get_singleton()->add_control_to_left_panel(p_control);
  370. } break;
  371. case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
  372. Node3DEditor::get_singleton()->add_control_to_right_panel(p_control);
  373. } break;
  374. case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
  375. Node3DEditor::get_singleton()->get_shader_split()->add_child(p_control);
  376. } break;
  377. case CONTAINER_CANVAS_EDITOR_MENU: {
  378. CanvasItemEditor::get_singleton()->add_control_to_menu_panel(p_control);
  379. } break;
  380. case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: {
  381. CanvasItemEditor::get_singleton()->add_control_to_left_panel(p_control);
  382. } break;
  383. case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: {
  384. CanvasItemEditor::get_singleton()->add_control_to_right_panel(p_control);
  385. } break;
  386. case CONTAINER_CANVAS_EDITOR_BOTTOM: {
  387. CanvasItemEditor::get_singleton()->get_bottom_split()->add_child(p_control);
  388. } break;
  389. case CONTAINER_INSPECTOR_BOTTOM: {
  390. InspectorDock::get_singleton()->get_addon_area()->add_child(p_control);
  391. } break;
  392. case CONTAINER_PROJECT_SETTING_TAB_LEFT: {
  393. ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control);
  394. ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 0);
  395. } break;
  396. case CONTAINER_PROJECT_SETTING_TAB_RIGHT: {
  397. ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control);
  398. ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 1);
  399. } break;
  400. }
  401. }
  402. void EditorPlugin::remove_control_from_container(CustomControlContainer p_location, Control *p_control) {
  403. ERR_FAIL_NULL(p_control);
  404. switch (p_location) {
  405. case CONTAINER_TOOLBAR: {
  406. EditorNode::get_menu_hb()->remove_child(p_control);
  407. } break;
  408. case CONTAINER_SPATIAL_EDITOR_MENU: {
  409. Node3DEditor::get_singleton()->remove_control_from_menu_panel(p_control);
  410. } break;
  411. case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: {
  412. Node3DEditor::get_singleton()->remove_control_from_left_panel(p_control);
  413. } break;
  414. case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
  415. Node3DEditor::get_singleton()->remove_control_from_right_panel(p_control);
  416. } break;
  417. case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
  418. Node3DEditor::get_singleton()->get_shader_split()->remove_child(p_control);
  419. } break;
  420. case CONTAINER_CANVAS_EDITOR_MENU: {
  421. CanvasItemEditor::get_singleton()->remove_control_from_menu_panel(p_control);
  422. } break;
  423. case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: {
  424. CanvasItemEditor::get_singleton()->remove_control_from_left_panel(p_control);
  425. } break;
  426. case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: {
  427. CanvasItemEditor::get_singleton()->remove_control_from_right_panel(p_control);
  428. } break;
  429. case CONTAINER_CANVAS_EDITOR_BOTTOM: {
  430. CanvasItemEditor::get_singleton()->get_bottom_split()->remove_child(p_control);
  431. } break;
  432. case CONTAINER_INSPECTOR_BOTTOM: {
  433. InspectorDock::get_singleton()->get_addon_area()->remove_child(p_control);
  434. } break;
  435. case CONTAINER_PROJECT_SETTING_TAB_LEFT:
  436. case CONTAINER_PROJECT_SETTING_TAB_RIGHT: {
  437. ProjectSettingsEditor::get_singleton()->get_tabs()->remove_child(p_control);
  438. } break;
  439. }
  440. }
  441. void EditorPlugin::add_tool_menu_item(const String &p_name, const Callable &p_callable) {
  442. EditorNode::get_singleton()->add_tool_menu_item(p_name, p_callable);
  443. }
  444. void EditorPlugin::add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu) {
  445. ERR_FAIL_NULL(p_submenu);
  446. EditorNode::get_singleton()->add_tool_submenu_item(p_name, p_submenu);
  447. }
  448. void EditorPlugin::remove_tool_menu_item(const String &p_name) {
  449. EditorNode::get_singleton()->remove_tool_menu_item(p_name);
  450. }
  451. PopupMenu *EditorPlugin::get_export_as_menu() {
  452. return EditorNode::get_singleton()->get_export_as_menu();
  453. }
  454. void EditorPlugin::set_input_event_forwarding_always_enabled() {
  455. input_event_forwarding_always_enabled = true;
  456. EditorPluginList *always_input_forwarding_list = EditorNode::get_singleton()->get_editor_plugins_force_input_forwarding();
  457. always_input_forwarding_list->add_plugin(this);
  458. }
  459. void EditorPlugin::set_force_draw_over_forwarding_enabled() {
  460. force_draw_over_forwarding_enabled = true;
  461. EditorPluginList *always_draw_over_forwarding_list = EditorNode::get_singleton()->get_editor_plugins_force_over();
  462. always_draw_over_forwarding_list->add_plugin(this);
  463. }
  464. void EditorPlugin::notify_scene_changed(const Node *scn_root) {
  465. emit_signal(SNAME("scene_changed"), scn_root);
  466. }
  467. void EditorPlugin::notify_main_screen_changed(const String &screen_name) {
  468. if (screen_name == last_main_screen_name) {
  469. return;
  470. }
  471. emit_signal(SNAME("main_screen_changed"), screen_name);
  472. last_main_screen_name = screen_name;
  473. }
  474. void EditorPlugin::notify_scene_closed(const String &scene_filepath) {
  475. emit_signal(SNAME("scene_closed"), scene_filepath);
  476. }
  477. void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) {
  478. emit_signal(SNAME("resource_saved"), p_resource);
  479. }
  480. bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
  481. bool success = false;
  482. GDVIRTUAL_CALL(_forward_canvas_gui_input, p_event, success);
  483. return success;
  484. }
  485. void EditorPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
  486. GDVIRTUAL_CALL(_forward_canvas_draw_over_viewport, p_overlay);
  487. }
  488. void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
  489. GDVIRTUAL_CALL(_forward_canvas_force_draw_over_viewport, p_overlay);
  490. }
  491. // Updates the overlays of the 2D viewport or, if in 3D mode, of every 3D viewport.
  492. int EditorPlugin::update_overlays() const {
  493. if (Node3DEditor::get_singleton()->is_visible()) {
  494. int count = 0;
  495. for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) {
  496. Node3DEditorViewport *vp = Node3DEditor::get_singleton()->get_editor_viewport(i);
  497. if (vp->is_visible()) {
  498. vp->update_surface();
  499. count++;
  500. }
  501. }
  502. return count;
  503. } else {
  504. // This will update the normal viewport itself as well
  505. CanvasItemEditor::get_singleton()->get_viewport_control()->queue_redraw();
  506. return 1;
  507. }
  508. }
  509. EditorPlugin::AfterGUIInput EditorPlugin::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
  510. int success = EditorPlugin::AFTER_GUI_INPUT_PASS;
  511. GDVIRTUAL_CALL(_forward_3d_gui_input, p_camera, p_event, success);
  512. return static_cast<EditorPlugin::AfterGUIInput>(success);
  513. }
  514. void EditorPlugin::forward_3d_draw_over_viewport(Control *p_overlay) {
  515. GDVIRTUAL_CALL(_forward_3d_draw_over_viewport, p_overlay);
  516. }
  517. void EditorPlugin::forward_3d_force_draw_over_viewport(Control *p_overlay) {
  518. GDVIRTUAL_CALL(_forward_3d_force_draw_over_viewport, p_overlay);
  519. }
  520. String EditorPlugin::get_name() const {
  521. String name;
  522. GDVIRTUAL_CALL(_get_plugin_name, name);
  523. return name;
  524. }
  525. const Ref<Texture2D> EditorPlugin::get_icon() const {
  526. Ref<Texture2D> icon;
  527. GDVIRTUAL_CALL(_get_plugin_icon, icon);
  528. return icon;
  529. }
  530. bool EditorPlugin::has_main_screen() const {
  531. bool success = false;
  532. GDVIRTUAL_CALL(_has_main_screen, success);
  533. return success;
  534. }
  535. void EditorPlugin::make_visible(bool p_visible) {
  536. GDVIRTUAL_CALL(_make_visible, p_visible);
  537. }
  538. void EditorPlugin::edit(Object *p_object) {
  539. GDVIRTUAL_CALL(_edit, p_object);
  540. }
  541. bool EditorPlugin::handles(Object *p_object) const {
  542. bool success = false;
  543. GDVIRTUAL_CALL(_handles, p_object, success);
  544. return success;
  545. }
  546. Dictionary EditorPlugin::get_state() const {
  547. Dictionary state;
  548. GDVIRTUAL_CALL(_get_state, state);
  549. return state;
  550. }
  551. void EditorPlugin::set_state(const Dictionary &p_state) {
  552. GDVIRTUAL_CALL(_set_state, p_state);
  553. }
  554. void EditorPlugin::clear() {
  555. GDVIRTUAL_CALL(_clear);
  556. }
  557. // if editor references external resources/scenes, save them
  558. void EditorPlugin::save_external_data() {
  559. GDVIRTUAL_CALL(_save_external_data);
  560. }
  561. // if changes are pending in editor, apply them
  562. void EditorPlugin::apply_changes() {
  563. GDVIRTUAL_CALL(_apply_changes);
  564. }
  565. void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
  566. PackedStringArray arr;
  567. if (GDVIRTUAL_CALL(_get_breakpoints, arr)) {
  568. for (int i = 0; i < arr.size(); i++) {
  569. p_breakpoints->push_back(arr[i]);
  570. }
  571. }
  572. }
  573. bool EditorPlugin::get_remove_list(List<Node *> *p_list) {
  574. return false;
  575. }
  576. void EditorPlugin::add_undo_redo_inspector_hook_callback(Callable p_callable) {
  577. EditorNode::get_singleton()->get_editor_data().add_undo_redo_inspector_hook_callback(p_callable);
  578. }
  579. void EditorPlugin::remove_undo_redo_inspector_hook_callback(Callable p_callable) {
  580. EditorNode::get_singleton()->get_editor_data().remove_undo_redo_inspector_hook_callback(p_callable);
  581. }
  582. void EditorPlugin::add_translation_parser_plugin(const Ref<EditorTranslationParserPlugin> &p_parser) {
  583. ERR_FAIL_COND(!p_parser.is_valid());
  584. EditorTranslationParser::get_singleton()->add_parser(p_parser, EditorTranslationParser::CUSTOM);
  585. }
  586. void EditorPlugin::remove_translation_parser_plugin(const Ref<EditorTranslationParserPlugin> &p_parser) {
  587. ERR_FAIL_COND(!p_parser.is_valid());
  588. EditorTranslationParser::get_singleton()->remove_parser(p_parser, EditorTranslationParser::CUSTOM);
  589. }
  590. void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin> &p_importer, bool p_first_priority) {
  591. ERR_FAIL_COND(!p_importer.is_valid());
  592. ResourceFormatImporter::get_singleton()->add_importer(p_importer, p_first_priority);
  593. EditorFileSystem::get_singleton()->call_deferred(SNAME("scan"));
  594. }
  595. void EditorPlugin::remove_import_plugin(const Ref<EditorImportPlugin> &p_importer) {
  596. ERR_FAIL_COND(!p_importer.is_valid());
  597. ResourceFormatImporter::get_singleton()->remove_importer(p_importer);
  598. EditorFileSystem::get_singleton()->call_deferred(SNAME("scan"));
  599. }
  600. void EditorPlugin::add_export_plugin(const Ref<EditorExportPlugin> &p_exporter) {
  601. ERR_FAIL_COND(!p_exporter.is_valid());
  602. EditorExport::get_singleton()->add_export_plugin(p_exporter);
  603. }
  604. void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter) {
  605. ERR_FAIL_COND(!p_exporter.is_valid());
  606. EditorExport::get_singleton()->remove_export_plugin(p_exporter);
  607. }
  608. void EditorPlugin::add_node_3d_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
  609. ERR_FAIL_COND(!p_gizmo_plugin.is_valid());
  610. Node3DEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin);
  611. }
  612. void EditorPlugin::remove_node_3d_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
  613. ERR_FAIL_COND(!p_gizmo_plugin.is_valid());
  614. Node3DEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin);
  615. }
  616. void EditorPlugin::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
  617. ERR_FAIL_COND(!p_plugin.is_valid());
  618. EditorInspector::add_inspector_plugin(p_plugin);
  619. }
  620. void EditorPlugin::remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
  621. ERR_FAIL_COND(!p_plugin.is_valid());
  622. EditorInspector::remove_inspector_plugin(p_plugin);
  623. }
  624. void EditorPlugin::add_scene_format_importer_plugin(const Ref<EditorSceneFormatImporter> &p_importer, bool p_first_priority) {
  625. ERR_FAIL_COND(!p_importer.is_valid());
  626. ResourceImporterScene::add_importer(p_importer, p_first_priority);
  627. }
  628. void EditorPlugin::remove_scene_format_importer_plugin(const Ref<EditorSceneFormatImporter> &p_importer) {
  629. ERR_FAIL_COND(!p_importer.is_valid());
  630. ResourceImporterScene::remove_importer(p_importer);
  631. }
  632. void EditorPlugin::add_scene_post_import_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin, bool p_first_priority) {
  633. ResourceImporterScene::add_post_importer_plugin(p_plugin, p_first_priority);
  634. }
  635. void EditorPlugin::remove_scene_post_import_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin) {
  636. ResourceImporterScene::remove_post_importer_plugin(p_plugin);
  637. }
  638. int find(const PackedStringArray &a, const String &v) {
  639. const String *r = a.ptr();
  640. for (int j = 0; j < a.size(); ++j) {
  641. if (r[j] == v) {
  642. return j;
  643. }
  644. }
  645. return -1;
  646. }
  647. void EditorPlugin::enable_plugin() {
  648. // Called when the plugin gets enabled in project settings, after it's added to the tree.
  649. // You can implement it to register autoloads.
  650. GDVIRTUAL_CALL(_enable_plugin);
  651. }
  652. void EditorPlugin::disable_plugin() {
  653. // Last function called when the plugin gets disabled in project settings.
  654. // Implement it to cleanup things from the project, such as unregister autoloads.
  655. GDVIRTUAL_CALL(_disable_plugin);
  656. }
  657. void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
  658. GDVIRTUAL_CALL(_set_window_layout, p_layout);
  659. }
  660. void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
  661. GDVIRTUAL_CALL(_get_window_layout, p_layout);
  662. }
  663. bool EditorPlugin::build() {
  664. bool success = true;
  665. GDVIRTUAL_CALL(_build, success);
  666. return success;
  667. }
  668. void EditorPlugin::queue_save_layout() {
  669. EditorNode::get_singleton()->save_layout();
  670. }
  671. void EditorPlugin::make_bottom_panel_item_visible(Control *p_item) {
  672. EditorNode::get_singleton()->make_bottom_panel_item_visible(p_item);
  673. }
  674. void EditorPlugin::hide_bottom_panel() {
  675. EditorNode::get_singleton()->hide_bottom_panel();
  676. }
  677. EditorInterface *EditorPlugin::get_editor_interface() {
  678. return EditorInterface::get_singleton();
  679. }
  680. ScriptCreateDialog *EditorPlugin::get_script_create_dialog() {
  681. return SceneTreeDock::get_singleton()->get_script_create_dialog();
  682. }
  683. void EditorPlugin::add_debugger_plugin(const Ref<EditorDebuggerPlugin> &p_plugin) {
  684. EditorDebuggerNode::get_singleton()->add_debugger_plugin(p_plugin);
  685. }
  686. void EditorPlugin::remove_debugger_plugin(const Ref<EditorDebuggerPlugin> &p_plugin) {
  687. EditorDebuggerNode::get_singleton()->remove_debugger_plugin(p_plugin);
  688. }
  689. void EditorPlugin::add_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin) {
  690. EditorNode::get_singleton()->add_resource_conversion_plugin(p_plugin);
  691. }
  692. void EditorPlugin::remove_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin) {
  693. EditorNode::get_singleton()->remove_resource_conversion_plugin(p_plugin);
  694. }
  695. void EditorPlugin::_editor_project_settings_changed() {
  696. emit_signal(SNAME("project_settings_changed"));
  697. }
  698. void EditorPlugin::_notification(int p_what) {
  699. switch (p_what) {
  700. case NOTIFICATION_ENTER_TREE: {
  701. EditorNode::get_singleton()->connect("project_settings_changed", callable_mp(this, &EditorPlugin::_editor_project_settings_changed));
  702. } break;
  703. case NOTIFICATION_EXIT_TREE: {
  704. EditorNode::get_singleton()->disconnect("project_settings_changed", callable_mp(this, &EditorPlugin::_editor_project_settings_changed));
  705. } break;
  706. }
  707. }
  708. void EditorPlugin::_bind_methods() {
  709. ClassDB::bind_method(D_METHOD("add_control_to_container", "container", "control"), &EditorPlugin::add_control_to_container);
  710. ClassDB::bind_method(D_METHOD("add_control_to_bottom_panel", "control", "title"), &EditorPlugin::add_control_to_bottom_panel);
  711. ClassDB::bind_method(D_METHOD("add_control_to_dock", "slot", "control"), &EditorPlugin::add_control_to_dock);
  712. ClassDB::bind_method(D_METHOD("remove_control_from_docks", "control"), &EditorPlugin::remove_control_from_docks);
  713. ClassDB::bind_method(D_METHOD("remove_control_from_bottom_panel", "control"), &EditorPlugin::remove_control_from_bottom_panel);
  714. ClassDB::bind_method(D_METHOD("remove_control_from_container", "container", "control"), &EditorPlugin::remove_control_from_container);
  715. ClassDB::bind_method(D_METHOD("add_tool_menu_item", "name", "callable"), &EditorPlugin::add_tool_menu_item);
  716. ClassDB::bind_method(D_METHOD("add_tool_submenu_item", "name", "submenu"), &EditorPlugin::add_tool_submenu_item);
  717. ClassDB::bind_method(D_METHOD("remove_tool_menu_item", "name"), &EditorPlugin::remove_tool_menu_item);
  718. ClassDB::bind_method(D_METHOD("get_export_as_menu"), &EditorPlugin::get_export_as_menu);
  719. ClassDB::bind_method(D_METHOD("add_custom_type", "type", "base", "script", "icon"), &EditorPlugin::add_custom_type);
  720. ClassDB::bind_method(D_METHOD("remove_custom_type", "type"), &EditorPlugin::remove_custom_type);
  721. ClassDB::bind_method(D_METHOD("add_autoload_singleton", "name", "path"), &EditorPlugin::add_autoload_singleton);
  722. ClassDB::bind_method(D_METHOD("remove_autoload_singleton", "name"), &EditorPlugin::remove_autoload_singleton);
  723. ClassDB::bind_method(D_METHOD("update_overlays"), &EditorPlugin::update_overlays);
  724. ClassDB::bind_method(D_METHOD("make_bottom_panel_item_visible", "item"), &EditorPlugin::make_bottom_panel_item_visible);
  725. ClassDB::bind_method(D_METHOD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
  726. ClassDB::bind_method(D_METHOD("get_undo_redo"), &EditorPlugin::get_undo_redo);
  727. ClassDB::bind_method(D_METHOD("add_undo_redo_inspector_hook_callback", "callable"), &EditorPlugin::add_undo_redo_inspector_hook_callback);
  728. ClassDB::bind_method(D_METHOD("remove_undo_redo_inspector_hook_callback", "callable"), &EditorPlugin::remove_undo_redo_inspector_hook_callback);
  729. ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout);
  730. ClassDB::bind_method(D_METHOD("add_translation_parser_plugin", "parser"), &EditorPlugin::add_translation_parser_plugin);
  731. ClassDB::bind_method(D_METHOD("remove_translation_parser_plugin", "parser"), &EditorPlugin::remove_translation_parser_plugin);
  732. ClassDB::bind_method(D_METHOD("add_import_plugin", "importer", "first_priority"), &EditorPlugin::add_import_plugin, DEFVAL(false));
  733. ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer"), &EditorPlugin::remove_import_plugin);
  734. ClassDB::bind_method(D_METHOD("add_scene_format_importer_plugin", "scene_format_importer", "first_priority"), &EditorPlugin::add_scene_format_importer_plugin, DEFVAL(false));
  735. ClassDB::bind_method(D_METHOD("remove_scene_format_importer_plugin", "scene_format_importer"), &EditorPlugin::remove_scene_format_importer_plugin);
  736. ClassDB::bind_method(D_METHOD("add_scene_post_import_plugin", "scene_import_plugin", "first_priority"), &EditorPlugin::add_scene_post_import_plugin, DEFVAL(false));
  737. ClassDB::bind_method(D_METHOD("remove_scene_post_import_plugin", "scene_import_plugin"), &EditorPlugin::remove_scene_post_import_plugin);
  738. ClassDB::bind_method(D_METHOD("add_export_plugin", "plugin"), &EditorPlugin::add_export_plugin);
  739. ClassDB::bind_method(D_METHOD("remove_export_plugin", "plugin"), &EditorPlugin::remove_export_plugin);
  740. ClassDB::bind_method(D_METHOD("add_node_3d_gizmo_plugin", "plugin"), &EditorPlugin::add_node_3d_gizmo_plugin);
  741. ClassDB::bind_method(D_METHOD("remove_node_3d_gizmo_plugin", "plugin"), &EditorPlugin::remove_node_3d_gizmo_plugin);
  742. ClassDB::bind_method(D_METHOD("add_inspector_plugin", "plugin"), &EditorPlugin::add_inspector_plugin);
  743. ClassDB::bind_method(D_METHOD("remove_inspector_plugin", "plugin"), &EditorPlugin::remove_inspector_plugin);
  744. ClassDB::bind_method(D_METHOD("add_resource_conversion_plugin", "plugin"), &EditorPlugin::add_resource_conversion_plugin);
  745. ClassDB::bind_method(D_METHOD("remove_resource_conversion_plugin", "plugin"), &EditorPlugin::remove_resource_conversion_plugin);
  746. ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
  747. ClassDB::bind_method(D_METHOD("set_force_draw_over_forwarding_enabled"), &EditorPlugin::set_force_draw_over_forwarding_enabled);
  748. ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorPlugin::get_editor_interface);
  749. ClassDB::bind_method(D_METHOD("get_script_create_dialog"), &EditorPlugin::get_script_create_dialog);
  750. ClassDB::bind_method(D_METHOD("add_debugger_plugin", "script"), &EditorPlugin::add_debugger_plugin);
  751. ClassDB::bind_method(D_METHOD("remove_debugger_plugin", "script"), &EditorPlugin::remove_debugger_plugin);
  752. GDVIRTUAL_BIND(_forward_canvas_gui_input, "event");
  753. GDVIRTUAL_BIND(_forward_canvas_draw_over_viewport, "viewport_control");
  754. GDVIRTUAL_BIND(_forward_canvas_force_draw_over_viewport, "viewport_control");
  755. GDVIRTUAL_BIND(_forward_3d_gui_input, "viewport_camera", "event");
  756. GDVIRTUAL_BIND(_forward_3d_draw_over_viewport, "viewport_control");
  757. GDVIRTUAL_BIND(_forward_3d_force_draw_over_viewport, "viewport_control");
  758. GDVIRTUAL_BIND(_get_plugin_name);
  759. GDVIRTUAL_BIND(_get_plugin_icon);
  760. GDVIRTUAL_BIND(_has_main_screen);
  761. GDVIRTUAL_BIND(_make_visible, "visible");
  762. GDVIRTUAL_BIND(_edit, "object");
  763. GDVIRTUAL_BIND(_handles, "object");
  764. GDVIRTUAL_BIND(_get_state);
  765. GDVIRTUAL_BIND(_set_state, "state");
  766. GDVIRTUAL_BIND(_clear);
  767. GDVIRTUAL_BIND(_save_external_data);
  768. GDVIRTUAL_BIND(_apply_changes);
  769. GDVIRTUAL_BIND(_get_breakpoints);
  770. GDVIRTUAL_BIND(_set_window_layout, "configuration");
  771. GDVIRTUAL_BIND(_get_window_layout, "configuration");
  772. GDVIRTUAL_BIND(_build);
  773. GDVIRTUAL_BIND(_enable_plugin);
  774. GDVIRTUAL_BIND(_disable_plugin);
  775. ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
  776. ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath")));
  777. ADD_SIGNAL(MethodInfo("main_screen_changed", PropertyInfo(Variant::STRING, "screen_name")));
  778. ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
  779. ADD_SIGNAL(MethodInfo("project_settings_changed"));
  780. BIND_ENUM_CONSTANT(CONTAINER_TOOLBAR);
  781. BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU);
  782. BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE_LEFT);
  783. BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT);
  784. BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_BOTTOM);
  785. BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_MENU);
  786. BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE_LEFT);
  787. BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT);
  788. BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_BOTTOM);
  789. BIND_ENUM_CONSTANT(CONTAINER_INSPECTOR_BOTTOM);
  790. BIND_ENUM_CONSTANT(CONTAINER_PROJECT_SETTING_TAB_LEFT);
  791. BIND_ENUM_CONSTANT(CONTAINER_PROJECT_SETTING_TAB_RIGHT);
  792. BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_UL);
  793. BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_BL);
  794. BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_UR);
  795. BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_BR);
  796. BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UL);
  797. BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BL);
  798. BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UR);
  799. BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BR);
  800. BIND_ENUM_CONSTANT(DOCK_SLOT_MAX);
  801. BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_PASS);
  802. BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_STOP);
  803. BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_CUSTOM);
  804. }
  805. EditorUndoRedoManager *EditorPlugin::get_undo_redo() {
  806. return EditorUndoRedoManager::get_singleton();
  807. }
  808. EditorPluginCreateFunc EditorPlugins::creation_funcs[MAX_CREATE_FUNCS];
  809. int EditorPlugins::creation_func_count = 0;