editor_plugin.cpp 38 KB

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