EditorNode: Add function to load file as scene or resource

This commit is contained in:
Lars Pettersson 2024-12-28 17:40:50 +01:00
parent c2ba0a8646
commit d2d02d0ea8
No known key found for this signature in database
GPG key ID: CC050E7B46DF7540
16 changed files with 57 additions and 142 deletions

View file

@ -975,19 +975,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
if (ScriptServer::is_global_class(p_symbol)) {
EditorNode::get_singleton()->load_resource(ScriptServer::get_global_class_path(p_symbol));
} else if (p_symbol.is_resource_file() || p_symbol.begins_with("uid://")) {
String symbol = p_symbol;
if (symbol.begins_with("uid://")) {
symbol = ResourceUID::uid_to_path(symbol);
}
List<String> scene_extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
if (scene_extensions.find(symbol.get_extension())) {
EditorNode::get_singleton()->load_scene(symbol);
} else {
EditorNode::get_singleton()->load_resource(symbol);
}
EditorNode::get_singleton()->load_scene_or_resource(p_symbol);
} else if (lc_error == OK) {
_goto_line(p_row);
@ -1082,14 +1070,7 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
// Every symbol other than absolute path is relative path so keep this condition at last.
String path = _get_absolute_path(p_symbol);
if (FileAccess::exists(path)) {
List<String> scene_extensions;
ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
if (scene_extensions.find(path.get_extension())) {
EditorNode::get_singleton()->load_scene(path);
} else {
EditorNode::get_singleton()->load_resource(path);
}
EditorNode::get_singleton()->load_scene_or_resource(path);
}
}
}