From 2df37a237a4b2d1fb8c39078b4d320dc92050800 Mon Sep 17 00:00:00 2001 From: 398utubzyt <398utubzyt@gmail.com> Date: Tue, 23 May 2023 09:25:34 -0700 Subject: [PATCH] C#: Abstract script class support --- core/object/class_db.cpp | 14 +++++++++++-- core/object/object.cpp | 5 ++++- core/object/script_language.cpp | 1 + core/object/script_language.h | 1 + core/object/script_language_extension.cpp | 1 + core/object/script_language_extension.h | 6 ++++++ doc/classes/Script.xml | 6 ++++++ doc/classes/ScriptExtension.xml | 6 ++++++ editor/create_dialog.cpp | 10 +++++++-- editor/editor_resource_picker.cpp | 2 +- modules/gdscript/gdscript.h | 1 + modules/mono/csharp_script.cpp | 21 +++++++++++-------- modules/mono/csharp_script.h | 4 ++++ .../Core/Bridge/ManagedCallbacks.cs | 2 +- .../Core/Bridge/ScriptManagerBridge.cs | 11 +++++++--- modules/mono/mono_gd/gd_mono_cache.h | 2 +- 16 files changed, 73 insertions(+), 20 deletions(-) diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index 100cb8e6a20..26ccf07320e 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -31,6 +31,7 @@ #include "class_db.h" #include "core/config/engine.h" +#include "core/io/resource_loader.h" #include "core/object/script_language.h" #include "core/os/mutex.h" #include "core/version.h" @@ -377,7 +378,14 @@ bool ClassDB::can_instantiate(const StringName &p_class) { OBJTYPE_RLOCK; ClassInfo *ti = classes.getptr(p_class); - ERR_FAIL_NULL_V_MSG(ti, false, "Cannot get class '" + String(p_class) + "'."); + if (!ti) { + if (!ScriptServer::is_global_class(p_class)) { + ERR_FAIL_V_MSG(false, "Cannot get class '" + String(p_class) + "'."); + } + String path = ScriptServer::get_global_class_path(p_class); + Ref