diff --git a/src/editor/generate_csharp_bindings.cpp b/src/editor/generate_csharp_bindings.cpp index c2c68de6..d755326a 100644 --- a/src/editor/generate_csharp_bindings.cpp +++ b/src/editor/generate_csharp_bindings.cpp @@ -30,6 +30,13 @@ bool GenerateCSharpBindingsPlugin::is_need_to_update() { if (!ClassDB::class_exists("CSharpScript")) return false; + // Old file name + const String old_api_path = output_directory.path_join("DebugDrawGeneratedAPI.cs"); + if (FileAccess::file_exists(old_api_path)) { + return true; + } + + const String api_path = output_directory.path_join(api_file_name); if (FileAccess::file_exists(api_path)) { auto file = FileAccess::open(api_path, FileAccess::READ); @@ -61,6 +68,14 @@ void GenerateCSharpBindingsPlugin::generate() { } } + // Delete the file with the older naming convention + const String old_api_path = output_directory.path_join("DebugDrawGeneratedAPI.cs"); + if (FileAccess::file_exists(old_api_path)) { + PRINT("Attempt to delete API file with older naming convention: " + out_path); + ERR_FAIL_COND(dir->remove(old_api_path) != Error::OK); + } + + // First, delete the old file to check for locks if (FileAccess::file_exists(out_path)) { PRINT("Attempt to delete an old file: " + out_path); diff --git a/src/editor/generate_csharp_bindings.h b/src/editor/generate_csharp_bindings.h index aee84bdb..be835cef 100644 --- a/src/editor/generate_csharp_bindings.h +++ b/src/editor/generate_csharp_bindings.h @@ -80,7 +80,7 @@ class GenerateCSharpBindingsPlugin { }; String output_directory = "res://addons/debug_draw_3d/gen/csharp"; - String api_file_name = "DebugDrawGeneratedAPI.cs"; + String api_file_name = "DebugDrawGeneratedAPI.generated.cs"; String log_file_name = "log.txt"; String indent_template = " "; String indent; @@ -171,4 +171,4 @@ class GenerateCSharpBindingsPlugin { IndentGuard tab(); }; -#endif \ No newline at end of file +#endif