You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Optimize class icon loading
`get_global_class_name` for `GDScriptLanguage` is slow because it forces to parse an entire script each time. This patch ensures that the icon is actually fetched from the EditorData where they are loaded beforehand. This change also makes the behavior consistent with the existing `get_object_icon` method in EditorNode.
This commit is contained in:
@@ -3642,17 +3642,12 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ScriptServer::is_global_class(p_class)) {
|
if (ScriptServer::is_global_class(p_class)) {
|
||||||
String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(p_class);
|
Ref<ImageTexture> icon;
|
||||||
Ref<ImageTexture> icon = _load_custom_class_icon(icon_path);
|
Ref<Script> script = EditorNode::get_editor_data().script_class_load_script(p_class);
|
||||||
if (icon.is_valid()) {
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(p_class), "Script");
|
|
||||||
|
|
||||||
while (script.is_valid()) {
|
while (script.is_valid()) {
|
||||||
String current_icon_path;
|
StringName name = EditorNode::get_editor_data().script_class_get_name(script->get_path());
|
||||||
script->get_language()->get_global_class_name(script->get_path(), nullptr, ¤t_icon_path);
|
String current_icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name);
|
||||||
icon = _load_custom_class_icon(current_icon_path);
|
icon = _load_custom_class_icon(current_icon_path);
|
||||||
if (icon.is_valid()) {
|
if (icon.is_valid()) {
|
||||||
return icon;
|
return icon;
|
||||||
|
|||||||
Reference in New Issue
Block a user