editor_plugin.cpp 40 KB

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