Instantiate global classes properly, fixes #20857

This commit is contained in:
Juan Linietsky 2019-01-27 18:18:12 -03:00
parent d0f289b0d9
commit 98ffb6b37e
1 changed files with 13 additions and 1 deletions

View File

@ -2187,7 +2187,19 @@ void EditorPropertyResource::_menu_option(int p_which) {
return; return;
} }
Object *obj = ClassDB::instance(intype); Object *obj = NULL;
if (ScriptServer::is_global_class(intype)) {
obj = ClassDB::instance(ScriptServer::get_global_class_base(intype));
if (obj) {
Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(intype));
if (script.is_valid()) {
obj->set_script(Variant(script));
}
}
} else {
obj = ClassDB::instance(intype);
}
if (!obj) { if (!obj) {
obj = EditorNode::get_editor_data().instance_custom_type(intype, "Resource"); obj = EditorNode::get_editor_data().instance_custom_type(intype, "Resource");