godotsharp_editor.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. /*************************************************************************/
  2. /* godotsharp_editor.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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 "godotsharp_editor.h"
  31. #include "core/message_queue.h"
  32. #include "core/os/os.h"
  33. #include "core/project_settings.h"
  34. #include "scene/gui/control.h"
  35. #include "scene/main/node.h"
  36. #include "../csharp_script.h"
  37. #include "../godotsharp_dirs.h"
  38. #include "../mono_gd/gd_mono.h"
  39. #include "../mono_gd/gd_mono_marshal.h"
  40. #include "../utils/path_utils.h"
  41. #include "bindings_generator.h"
  42. #include "csharp_project.h"
  43. #include "dotnet_solution.h"
  44. #include "godotsharp_export.h"
  45. #ifdef OSX_ENABLED
  46. #include "../utils/osx_utils.h"
  47. #endif
  48. #ifdef WINDOWS_ENABLED
  49. #include "../utils/mono_reg_utils.h"
  50. #endif
  51. GodotSharpEditor *GodotSharpEditor::singleton = NULL;
  52. bool GodotSharpEditor::_create_project_solution() {
  53. EditorProgress pr("create_csharp_solution", TTR("Generating solution..."), 2);
  54. pr.step(TTR("Generating C# project..."));
  55. String path = OS::get_singleton()->get_resource_dir();
  56. String appname = ProjectSettings::get_singleton()->get("application/config/name");
  57. String appname_safe = OS::get_singleton()->get_safe_dir_name(appname);
  58. if (appname_safe.empty()) {
  59. appname_safe = "UnnamedProject";
  60. }
  61. String guid = CSharpProject::generate_game_project(path, appname_safe);
  62. if (guid.length()) {
  63. DotNetSolution solution(appname_safe);
  64. if (!solution.set_path(path)) {
  65. show_error_dialog(TTR("Failed to create solution."));
  66. return false;
  67. }
  68. DotNetSolution::ProjectInfo proj_info;
  69. proj_info.guid = guid;
  70. proj_info.relpath = appname_safe + ".csproj";
  71. proj_info.configs.push_back("Debug");
  72. proj_info.configs.push_back("Release");
  73. proj_info.configs.push_back("Tools");
  74. solution.add_new_project(appname_safe, proj_info);
  75. Error sln_error = solution.save();
  76. if (sln_error != OK) {
  77. show_error_dialog(TTR("Failed to save solution."));
  78. return false;
  79. }
  80. if (!GodotSharpBuilds::make_api_assembly(APIAssembly::API_CORE))
  81. return false;
  82. if (!GodotSharpBuilds::make_api_assembly(APIAssembly::API_EDITOR))
  83. return false;
  84. pr.step(TTR("Done"));
  85. // Here, after all calls to progress_task_step
  86. call_deferred("_remove_create_sln_menu_option");
  87. } else {
  88. show_error_dialog(TTR("Failed to create C# project."));
  89. }
  90. return true;
  91. }
  92. void GodotSharpEditor::_make_api_solutions_if_needed() {
  93. // I'm sick entirely of ProgressDialog
  94. static int attempts_left = 100;
  95. if (MessageQueue::get_singleton()->is_flushing() || !SceneTree::get_singleton()) {
  96. ERR_FAIL_COND(attempts_left == 0); // You've got to be kidding
  97. if (SceneTree::get_singleton()) {
  98. SceneTree::get_singleton()->connect("idle_frame", this, "_make_api_solutions_if_needed", Vector<Variant>());
  99. } else {
  100. call_deferred("_make_api_solutions_if_needed");
  101. }
  102. attempts_left--;
  103. return;
  104. }
  105. // Recursion guard needed because signals don't play well with ProgressDialog either, but unlike
  106. // the message queue, with signals the collateral damage should be minimal in the worst case.
  107. static bool recursion_guard = false;
  108. if (!recursion_guard) {
  109. recursion_guard = true;
  110. // Oneshot signals don't play well with ProgressDialog either, so we do it this way instead
  111. SceneTree::get_singleton()->disconnect("idle_frame", this, "_make_api_solutions_if_needed");
  112. _make_api_solutions_if_needed_impl();
  113. recursion_guard = false;
  114. }
  115. }
  116. void GodotSharpEditor::_make_api_solutions_if_needed_impl() {
  117. // If the project has a solution and C# project make sure the API assemblies are present and up to date
  118. String res_assemblies_dir = GodotSharpDirs::get_res_assemblies_dir();
  119. if (!FileAccess::exists(res_assemblies_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll")) ||
  120. GDMono::get_singleton()->metadata_is_api_assembly_invalidated(APIAssembly::API_CORE)) {
  121. if (!GodotSharpBuilds::make_api_assembly(APIAssembly::API_CORE))
  122. return;
  123. }
  124. if (!FileAccess::exists(res_assemblies_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll")) ||
  125. GDMono::get_singleton()->metadata_is_api_assembly_invalidated(APIAssembly::API_EDITOR)) {
  126. if (!GodotSharpBuilds::make_api_assembly(APIAssembly::API_EDITOR))
  127. return; // Redundant? I don't think so
  128. }
  129. }
  130. void GodotSharpEditor::_remove_create_sln_menu_option() {
  131. menu_popup->remove_item(menu_popup->get_item_index(MENU_CREATE_SLN));
  132. bottom_panel_btn->show();
  133. }
  134. void GodotSharpEditor::_show_about_dialog() {
  135. bool show_on_start = EDITOR_GET("mono/editor/show_info_on_start");
  136. about_dialog_checkbox->set_pressed(show_on_start);
  137. about_dialog->popup_centered_minsize();
  138. }
  139. void GodotSharpEditor::_toggle_about_dialog_on_start(bool p_enabled) {
  140. bool show_on_start = EDITOR_GET("mono/editor/show_info_on_start");
  141. if (show_on_start != p_enabled) {
  142. EditorSettings::get_singleton()->set_setting("mono/editor/show_info_on_start", p_enabled);
  143. }
  144. }
  145. void GodotSharpEditor::_build_solution_pressed() {
  146. if (!FileAccess::exists(GodotSharpDirs::get_project_sln_path())) {
  147. if (!_create_project_solution())
  148. return; // Failed to create solution
  149. }
  150. MonoBottomPanel::get_singleton()->call("_build_project_pressed");
  151. }
  152. void GodotSharpEditor::_menu_option_pressed(int p_id) {
  153. switch (p_id) {
  154. case MENU_CREATE_SLN: {
  155. _create_project_solution();
  156. } break;
  157. case MENU_ABOUT_CSHARP: {
  158. _show_about_dialog();
  159. } break;
  160. default:
  161. ERR_FAIL();
  162. }
  163. }
  164. void GodotSharpEditor::_notification(int p_notification) {
  165. switch (p_notification) {
  166. case NOTIFICATION_READY: {
  167. bool show_info_dialog = EDITOR_GET("mono/editor/show_info_on_start");
  168. if (show_info_dialog) {
  169. about_dialog->set_exclusive(true);
  170. _show_about_dialog();
  171. // Once shown a first time, it can be seen again via the Mono menu - it doesn't have to be exclusive then.
  172. about_dialog->set_exclusive(false);
  173. }
  174. }
  175. }
  176. }
  177. void GodotSharpEditor::_bind_methods() {
  178. ClassDB::bind_method(D_METHOD("_build_solution_pressed"), &GodotSharpEditor::_build_solution_pressed);
  179. ClassDB::bind_method(D_METHOD("_create_project_solution"), &GodotSharpEditor::_create_project_solution);
  180. ClassDB::bind_method(D_METHOD("_make_api_solutions_if_needed"), &GodotSharpEditor::_make_api_solutions_if_needed);
  181. ClassDB::bind_method(D_METHOD("_remove_create_sln_menu_option"), &GodotSharpEditor::_remove_create_sln_menu_option);
  182. ClassDB::bind_method(D_METHOD("_toggle_about_dialog_on_start"), &GodotSharpEditor::_toggle_about_dialog_on_start);
  183. ClassDB::bind_method(D_METHOD("_menu_option_pressed", "id"), &GodotSharpEditor::_menu_option_pressed);
  184. }
  185. MonoBoolean godot_icall_MonoDevelopInstance_IsApplicationBundleInstalled(MonoString *p_bundle_id) {
  186. #ifdef OSX_ENABLED
  187. return (MonoBoolean)osx_is_app_bundle_installed(GDMonoMarshal::mono_string_to_godot(p_bundle_id));
  188. #else
  189. (void)p_bundle_id; // UNUSED
  190. ERR_FAIL_V(false);
  191. #endif
  192. }
  193. MonoString *godot_icall_Utils_OS_GetPlatformName() {
  194. return GDMonoMarshal::mono_string_from_godot(OS::get_singleton()->get_name());
  195. }
  196. void GodotSharpEditor::register_internal_calls() {
  197. static bool registered = false;
  198. ERR_FAIL_COND(registered);
  199. registered = true;
  200. mono_add_internal_call("GodotSharpTools.Editor.MonoDevelopInstance::IsApplicationBundleInstalled", (void *)godot_icall_MonoDevelopInstance_IsApplicationBundleInstalled);
  201. mono_add_internal_call("GodotSharpTools.Utils.OS::GetPlatformName", (void *)godot_icall_Utils_OS_GetPlatformName);
  202. GodotSharpBuilds::register_internal_calls();
  203. GodotSharpExport::register_internal_calls();
  204. }
  205. void GodotSharpEditor::show_error_dialog(const String &p_message, const String &p_title) {
  206. error_dialog->set_title(p_title);
  207. error_dialog->set_text(p_message);
  208. error_dialog->popup_centered_minsize();
  209. }
  210. Error GodotSharpEditor::open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) {
  211. ExternalEditor editor = ExternalEditor(int(EditorSettings::get_singleton()->get("mono/editor/external_editor")));
  212. switch (editor) {
  213. case EDITOR_VSCODE: {
  214. static String vscode_path;
  215. if (vscode_path.empty() || !FileAccess::exists(vscode_path)) {
  216. // Try to search it again if it wasn't found last time or if it was removed from its location
  217. bool found = false;
  218. // TODO: Use initializer lists once C++11 is allowed
  219. static Vector<String> vscode_names;
  220. if (vscode_names.empty()) {
  221. vscode_names.push_back("code");
  222. vscode_names.push_back("code-oss");
  223. vscode_names.push_back("vscode");
  224. vscode_names.push_back("vscode-oss");
  225. vscode_names.push_back("visual-studio-code");
  226. vscode_names.push_back("visual-studio-code-oss");
  227. }
  228. for (int i = 0; i < vscode_names.size(); i++) {
  229. vscode_path = path_which(vscode_names[i]);
  230. if (!vscode_path.empty()) {
  231. found = true;
  232. break;
  233. }
  234. }
  235. if (!found)
  236. vscode_path.clear(); // Not found, clear so next time the empty() check is enough
  237. }
  238. List<String> args;
  239. #ifdef OSX_ENABLED
  240. // The package path is '/Applications/Visual Studio Code.app'
  241. static const String vscode_bundle_id = "com.microsoft.VSCode";
  242. static bool osx_app_bundle_installed = osx_is_app_bundle_installed(vscode_bundle_id);
  243. if (osx_app_bundle_installed) {
  244. args.push_back("-b");
  245. args.push_back(vscode_bundle_id);
  246. // The reusing of existing windows made by the 'open' command might not choose a wubdiw that is
  247. // editing our folder. It's better to ask for a new window and let VSCode do the window management.
  248. args.push_back("-n");
  249. // The open process must wait until the application finishes (which is instant in VSCode's case)
  250. args.push_back("--wait-apps");
  251. args.push_back("--args");
  252. }
  253. #endif
  254. args.push_back(ProjectSettings::get_singleton()->get_resource_path());
  255. String script_path = ProjectSettings::get_singleton()->globalize_path(p_script->get_path());
  256. if (p_line >= 0) {
  257. args.push_back("-g");
  258. args.push_back(script_path + ":" + itos(p_line + 1) + ":" + itos(p_col));
  259. } else {
  260. args.push_back(script_path);
  261. }
  262. #ifdef OSX_ENABLED
  263. ERR_EXPLAIN("Cannot find code editor: VSCode");
  264. ERR_FAIL_COND_V(!osx_app_bundle_installed && vscode_path.empty(), ERR_FILE_NOT_FOUND);
  265. String command = osx_app_bundle_installed ? "/usr/bin/open" : vscode_path;
  266. #else
  267. ERR_EXPLAIN("Cannot find code editor: VSCode");
  268. ERR_FAIL_COND_V(vscode_path.empty(), ERR_FILE_NOT_FOUND);
  269. String command = vscode_path;
  270. #endif
  271. Error err = OS::get_singleton()->execute(command, args, false);
  272. if (err != OK) {
  273. ERR_PRINT("Error when trying to execute code editor: VSCode");
  274. return err;
  275. }
  276. } break;
  277. #ifdef OSX_ENABLED
  278. case EDITOR_VISUALSTUDIO_MAC:
  279. // [[fallthrough]];
  280. #endif
  281. case EDITOR_MONODEVELOP: {
  282. #ifdef OSX_ENABLED
  283. bool is_visualstudio = editor == EDITOR_VISUALSTUDIO_MAC;
  284. MonoDevelopInstance **instance = is_visualstudio ?
  285. &visualstudio_mac_instance :
  286. &monodevelop_instance;
  287. MonoDevelopInstance::EditorId editor_id = is_visualstudio ?
  288. MonoDevelopInstance::VISUALSTUDIO_FOR_MAC :
  289. MonoDevelopInstance::MONODEVELOP;
  290. #else
  291. MonoDevelopInstance **instance = &monodevelop_instance;
  292. MonoDevelopInstance::EditorId editor_id = MonoDevelopInstance::MONODEVELOP;
  293. #endif
  294. if (!*instance)
  295. *instance = memnew(MonoDevelopInstance(GodotSharpDirs::get_project_sln_path(), editor_id));
  296. String script_path = ProjectSettings::get_singleton()->globalize_path(p_script->get_path());
  297. if (p_line >= 0) {
  298. script_path += ";" + itos(p_line + 1) + ";" + itos(p_col);
  299. }
  300. (*instance)->execute(script_path);
  301. } break;
  302. default:
  303. return ERR_UNAVAILABLE;
  304. }
  305. return OK;
  306. }
  307. bool GodotSharpEditor::overrides_external_editor() {
  308. return ExternalEditor(int(EditorSettings::get_singleton()->get("mono/editor/external_editor"))) != EDITOR_NONE;
  309. }
  310. GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) {
  311. singleton = this;
  312. monodevelop_instance = NULL;
  313. #ifdef OSX_ENABLED
  314. visualstudio_mac_instance = NULL;
  315. #endif
  316. editor = p_editor;
  317. error_dialog = memnew(AcceptDialog);
  318. editor->get_gui_base()->add_child(error_dialog);
  319. bottom_panel_btn = editor->add_bottom_panel_item(TTR("Mono"), memnew(MonoBottomPanel(editor)));
  320. godotsharp_builds = memnew(GodotSharpBuilds);
  321. editor->add_child(memnew(MonoReloadNode));
  322. menu_popup = memnew(PopupMenu);
  323. menu_popup->hide();
  324. menu_popup->set_as_toplevel(true);
  325. menu_popup->set_pass_on_modal_close_click(false);
  326. editor->add_tool_submenu_item("Mono", menu_popup);
  327. // TODO: Remove or edit this info dialog once Mono support is no longer in alpha
  328. {
  329. menu_popup->add_item(TTR("About C# support"), MENU_ABOUT_CSHARP);
  330. about_dialog = memnew(AcceptDialog);
  331. editor->get_gui_base()->add_child(about_dialog);
  332. about_dialog->set_title("Important: C# support is not feature-complete");
  333. // We don't use set_text() as the default AcceptDialog Label doesn't play well with the TextureRect and CheckBox
  334. // we'll add. Instead we add containers and a new autowrapped Label inside.
  335. // Main VBoxContainer (icon + label on top, checkbox at bottom)
  336. VBoxContainer *about_vbc = memnew(VBoxContainer);
  337. about_dialog->add_child(about_vbc);
  338. // HBoxContainer for icon + label
  339. HBoxContainer *about_hbc = memnew(HBoxContainer);
  340. about_vbc->add_child(about_hbc);
  341. TextureRect *about_icon = memnew(TextureRect);
  342. about_hbc->add_child(about_icon);
  343. Ref<Texture> about_icon_tex = about_icon->get_icon("NodeWarning", "EditorIcons");
  344. about_icon->set_texture(about_icon_tex);
  345. Label *about_label = memnew(Label);
  346. about_hbc->add_child(about_label);
  347. about_label->set_custom_minimum_size(Size2(600, 150) * EDSCALE);
  348. about_label->set_v_size_flags(Control::SIZE_EXPAND_FILL);
  349. about_label->set_autowrap(true);
  350. String about_text =
  351. String("C# support in Godot Engine is in late alpha stage and, while already usable, ") +
  352. "it is not meant for use in production.\n\n" +
  353. "Projects can be exported to Linux, macOS and Windows, but not yet to mobile or web platforms. " +
  354. "Bugs and usability issues will be addressed gradually over future releases, " +
  355. "potentially including compatibility breaking changes as new features are implemented for a better overall C# experience.\n\n" +
  356. "If you experience issues with this Mono build, please report them on Godot's issue tracker with details about your system, MSBuild version, IDE, etc.:\n\n" +
  357. " https://github.com/godotengine/godot/issues\n\n" +
  358. "Your critical feedback at this stage will play a great role in shaping the C# support in future releases, so thank you!";
  359. about_label->set_text(about_text);
  360. EDITOR_DEF("mono/editor/show_info_on_start", true);
  361. // CheckBox in main container
  362. about_dialog_checkbox = memnew(CheckBox);
  363. about_vbc->add_child(about_dialog_checkbox);
  364. about_dialog_checkbox->set_text("Show this warning when starting the editor");
  365. about_dialog_checkbox->connect("toggled", this, "_toggle_about_dialog_on_start");
  366. }
  367. String sln_path = GodotSharpDirs::get_project_sln_path();
  368. String csproj_path = GodotSharpDirs::get_project_csproj_path();
  369. if (FileAccess::exists(sln_path) && FileAccess::exists(csproj_path)) {
  370. // Defer this task because EditorProgress calls Main::iterarion() and the main loop is not yet initialized.
  371. call_deferred("_make_api_solutions_if_needed");
  372. } else {
  373. bottom_panel_btn->hide();
  374. menu_popup->add_item(TTR("Create C# solution"), MENU_CREATE_SLN);
  375. }
  376. menu_popup->connect("id_pressed", this, "_menu_option_pressed");
  377. ToolButton *build_button = memnew(ToolButton);
  378. build_button->set_text("Build");
  379. build_button->set_tooltip("Build solution");
  380. build_button->set_focus_mode(Control::FOCUS_NONE);
  381. build_button->connect("pressed", this, "_build_solution_pressed");
  382. editor->get_menu_hb()->add_child(build_button);
  383. // External editor settings
  384. EditorSettings *ed_settings = EditorSettings::get_singleton();
  385. EDITOR_DEF("mono/editor/external_editor", EDITOR_NONE);
  386. String settings_hint_str = "Disabled";
  387. #if defined(WINDOWS_ENABLED)
  388. settings_hint_str += ",MonoDevelop,Visual Studio Code";
  389. #elif defined(OSX_ENABLED)
  390. settings_hint_str += ",Visual Studio,MonoDevelop,Visual Studio Code";
  391. #elif defined(UNIX_ENABLED)
  392. settings_hint_str += ",MonoDevelop,Visual Studio Code";
  393. #endif
  394. ed_settings->add_property_hint(PropertyInfo(Variant::INT, "mono/editor/external_editor", PROPERTY_HINT_ENUM, settings_hint_str));
  395. // Export plugin
  396. Ref<GodotSharpExport> godotsharp_export;
  397. godotsharp_export.instance();
  398. EditorExport::get_singleton()->add_export_plugin(godotsharp_export);
  399. }
  400. GodotSharpEditor::~GodotSharpEditor() {
  401. singleton = NULL;
  402. memdelete(godotsharp_builds);
  403. if (monodevelop_instance) {
  404. memdelete(monodevelop_instance);
  405. monodevelop_instance = NULL;
  406. }
  407. }
  408. MonoReloadNode *MonoReloadNode::singleton = NULL;
  409. void MonoReloadNode::_reload_timer_timeout() {
  410. if (CSharpLanguage::get_singleton()->is_assembly_reloading_needed()) {
  411. CSharpLanguage::get_singleton()->reload_assemblies(false);
  412. }
  413. }
  414. void MonoReloadNode::restart_reload_timer() {
  415. reload_timer->stop();
  416. reload_timer->start();
  417. }
  418. void MonoReloadNode::_bind_methods() {
  419. ClassDB::bind_method(D_METHOD("_reload_timer_timeout"), &MonoReloadNode::_reload_timer_timeout);
  420. }
  421. void MonoReloadNode::_notification(int p_what) {
  422. switch (p_what) {
  423. case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
  424. restart_reload_timer();
  425. if (CSharpLanguage::get_singleton()->is_assembly_reloading_needed()) {
  426. CSharpLanguage::get_singleton()->reload_assemblies(false);
  427. }
  428. } break;
  429. default: {
  430. } break;
  431. };
  432. }
  433. MonoReloadNode::MonoReloadNode() {
  434. singleton = this;
  435. reload_timer = memnew(Timer);
  436. add_child(reload_timer);
  437. reload_timer->set_one_shot(false);
  438. reload_timer->set_wait_time(EDITOR_DEF("mono/assembly_watch_interval_sec", 0.5));
  439. reload_timer->connect("timeout", this, "_reload_timer_timeout");
  440. reload_timer->start();
  441. }
  442. MonoReloadNode::~MonoReloadNode() {
  443. singleton = NULL;
  444. }