Fixed root type failing to change if user provides a global class inherited from another global class.
Find the inherited native class (built-in) of the user provided global class (GDScript) by recursively checking up its inheritance chain until a valid native class is found. Previously it was only checking the class directly extended from it which could be another global class. Importing expects a native class for _internal_instantiate() to work.
This commit is contained in:
parent
533c616cb8
commit
a82a66ee7c
1 changed files with 3 additions and 1 deletions
|
@ -3022,7 +3022,9 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
|
|||
Ref<Script> root_script = nullptr;
|
||||
if (ScriptServer::is_global_class(root_type)) {
|
||||
root_script = ResourceLoader::load(ScriptServer::get_global_class_path(root_type));
|
||||
root_type = ScriptServer::get_global_class_base(root_type);
|
||||
// Global class script loaded, recursively check for native class the script inherits from.
|
||||
// Needed for ClassDB::instantiate() as it expects native class.
|
||||
root_type = ScriptServer::get_global_class_native_base(root_type);
|
||||
}
|
||||
if (scene->get_class_name() != root_type) {
|
||||
// If the user specified a Godot node type that does not match
|
||||
|
|
Loading…
Reference in a new issue