Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileSystem shows custom Resource icon of first external dependancy instead of correct icon #93874

Open
trickster721 opened this issue Jul 2, 2024 · 2 comments

Comments

@trickster721
Copy link

Tested versions

v4.3.beta2.official [b75f048]

System information

Godot v4.3.beta2 - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 (NVIDIA; 31.0.15.3623) - Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz (4 Threads)

Issue description

If a saved custom resource file contains an exported subresource, and that subresource script appears first in the list of dependencies, then the subresource icon will be shown in the FileSystem dock instead of the customized resource icon.

It looks like there's an assumption that the resource's own script would always be the first listed external dependency, but that's not the case, the order seems to shuffle unpredictably whenever the file is overwritten. Manually correcting the order in the .tscn file fixes the problem temporarily, but doesn't prevent the editor from suddenly changing it again later on.

Only the FileSystem dock is affected, the correct icon is still shown elsewhere in the editor.

This file shows the correct custom resource icon:

[gd_resource type="Resource" script_class="CustomResource" load_steps=4 format=3 uid="uid://becgbjt2xt25t"]

[ext_resource type="Script" path="res://scripts/custom_resource.gd" id="1_1ahaa"]
[ext_resource type="Script" path="res://scripts/sub_resource.gd" id="2_ra8cr"]

[sub_resource type="Resource" id="Resource_5gvxf"]
script = ExtResource("2_ra8cr")
some_value = 0

[resource]
script = ExtResource("1_1ahaa")
sub_resource = SubResource("Resource_5gvxf")

This file mistakenly shows the icon of the subresource, note the ext_resource order:

[gd_resource type="Resource" script_class="CustomResource" load_steps=4 format=3 uid="uid://dlvvxjopcqthw"]

[ext_resource type="Script" path="res://scripts/sub_resource.gd" id="2_lm6jx"]
[ext_resource type="Script" path="res://scripts/custom_resource.gd" id="1_efmpu"]

[sub_resource type="Resource" id="Resource_peacu"]
script = ExtResource("2_lm6jx")
some_value = 1

[resource]
script = ExtResource("1_efmpu")
sub_resource = SubResource("Resource_peacu")

Steps to reproduce

I couldn't find steps that would predictably make the editor reverse the dependency order of a file, but it's happening to me frequently with normal editing, so I assume the order just isn't guaranteed.

Minimal reproduction project (MRP)

file_icon_subresource_issue.zip

@trickster721
Copy link
Author

This feature was implemented by #77932, and it looks like this was a known potential issue with this workaround as mentioned here: #77932 (comment)

@Hilderin
Copy link
Contributor

Hilderin commented Jul 4, 2024

I looked a bit into this problem and I don't see an easy way to use the dependencies correctly to find the right custom icon. If we loop on all deps, how can we find the right one?

I suggest using the script class which is already available in EditorFileSystemDirectory::FileInfo.resource_script_class. Based on this class name, the icon path should be available with EditorData::script_class_get_icon_path. I think that before 4.3 it was not mandatory to have a class name for custom resource with icon, but how, I think it is? Maybe a fallback could be to use the first dependency when the resource does not have a class name?

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants