derkork / godot-resource-groups

An add-on for the Godot engine that simplifies handling of resources
MIT License
183 stars 6 forks source link

Not recognizing plaintext files in folder #8

Closed vaisko closed 2 months ago

vaisko commented 2 months ago

Hi, first of all thanks for the great plugin. It really helped solve my post-export issues.

I also wanted to use it as a temporary solution to link to a few plaintext files that are in my data structure. Unfortunately, I have encountered a bug when I try to include all .txt files from a folder.

Most of the time the plugin doesn't recognize any of the files. image image

I tried changing the file structure, filename and file location, but nothing seems to yield any different results.

Once I managed to get the plugin to recognize only 2 of the 5 txt files, but I haven't been able to reproduce this issue.

As you can see, with JSON, everything works as normal, so I am confident that I am using the plugin correctly. image image

Thanks again for the nice piece of software, hopefully this feedback proves useful.

Cheers -Vaisko

derkork commented 2 months ago

I did some testing on this. As it stands right now Godot doesn't consider .txt files to be resources, while .json files actually are a supported resource type.

The reason why it works for some of the .txt files is some internal editor ... creativity ... that somehow makes a .txt file a resource once it is opened at least once in the editor. I added 3 txt files to the project and initially they were not detected because the plugin checks if the resource is actually visible to the resource loader (it runs a ResourceLoader.exists(filename)). Once I opened one of the text files inside of the editor (by double-clicking it), suddenly this check returned true (probably because there is some editor magic shoehorning a text-file into a temporary resource so the editor can handle them as if they were resources (likely courtesy of this ticket https://github.com/godotengine/godot/issues/21787).

However at runtime this will not work, e.g. you cannot load a txt file with load("res://path/to/some.txt") and therefore also the resource group's load_* methods wouldn't work (that's why the plugin verifies that these resources actually can be seen by the resource loader). So as such, there is not a lot this plugin can do, because .txt files are not officially resources, hence they cannot be in a resource group.

I have added a warning to the code that should at least make people aware of this but ultimately the only fix is for the engine to recognize .txt files as resources.

vaisko commented 2 months ago

Thanks for the super quick response. Adding the warning should do the trick; although I am aware that I probably wasn't using the plugin as intended, I opened this ticket precisely because I couldn't find anything related to this in the documentation/readme.

Thanks again.