|
@@ -549,13 +549,13 @@ bool CSharpLanguage::handles_global_class_type(const String &p_type) const {
|
|
|
|
|
|
String CSharpLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const {
|
|
|
Ref<CSharpScript> scr = ResourceLoader::load(p_path, get_type());
|
|
|
- if (!scr.is_valid() || !scr->valid || !scr->global_class) {
|
|
|
- // Invalid script or the script is not a global class.
|
|
|
- return String();
|
|
|
- }
|
|
|
+ // Always assign r_base_type and r_icon_path, even if the script
|
|
|
+ // is not a global one. In the case that it is not a global script,
|
|
|
+ // return an empty string AFTER assigning the return parameters.
|
|
|
+ // See GDScriptLanguage::get_global_class_name() in modules/gdscript/gdscript.cpp
|
|
|
|
|
|
- String name = scr->class_name;
|
|
|
- if (unlikely(name.is_empty())) {
|
|
|
+ if (!scr.is_valid() || !scr->valid) {
|
|
|
+ // Invalid script.
|
|
|
return String();
|
|
|
}
|
|
|
|
|
@@ -582,7 +582,8 @@ String CSharpLanguage::get_global_class_name(const String &p_path, String *r_bas
|
|
|
*r_base_type = scr->get_instance_base_type();
|
|
|
}
|
|
|
}
|
|
|
- return name;
|
|
|
+
|
|
|
+ return scr->global_class ? scr->class_name : String();
|
|
|
}
|
|
|
|
|
|
String CSharpLanguage::debug_get_error() const {
|
|
@@ -2295,6 +2296,7 @@ void CSharpScript::reload_registered_script(Ref<CSharpScript> p_script) {
|
|
|
void CSharpScript::update_script_class_info(Ref<CSharpScript> p_script) {
|
|
|
bool tool = false;
|
|
|
bool global_class = false;
|
|
|
+ bool abstract_class = false;
|
|
|
|
|
|
// TODO: Use GDExtension godot_dictionary
|
|
|
Array methods_array;
|
|
@@ -2308,12 +2310,13 @@ void CSharpScript::update_script_class_info(Ref<CSharpScript> p_script) {
|
|
|
String icon_path;
|
|
|
Ref<CSharpScript> base_script;
|
|
|
GDMonoCache::managed_callbacks.ScriptManagerBridge_UpdateScriptClassInfo(
|
|
|
- p_script.ptr(), &class_name, &tool, &global_class, &icon_path,
|
|
|
+ p_script.ptr(), &class_name, &tool, &global_class, &abstract_class, &icon_path,
|
|
|
&methods_array, &rpc_functions_dict, &signals_dict, &base_script);
|
|
|
|
|
|
p_script->class_name = class_name;
|
|
|
p_script->tool = tool;
|
|
|
p_script->global_class = global_class;
|
|
|
+ p_script->abstract_class = abstract_class;
|
|
|
p_script->icon_path = icon_path;
|
|
|
|
|
|
p_script->rpc_config.clear();
|
|
@@ -2401,7 +2404,7 @@ bool CSharpScript::can_instantiate() const {
|
|
|
ERR_FAIL_V_MSG(false, "Cannot instance script because the associated class could not be found. Script: '" + get_path() + "'. Make sure the script exists and contains a class definition with a name that matches the filename of the script exactly (it's case-sensitive).");
|
|
|
}
|
|
|
|
|
|
- return valid && extra_cond;
|
|
|
+ return valid && !abstract_class && extra_cond;
|
|
|
}
|
|
|
|
|
|
StringName CSharpScript::get_instance_base_type() const {
|