-
-
Notifications
You must be signed in to change notification settings - Fork 23.5k
Add retrieval methods to ResourceLoader for querying cached resource paths (C++, C#, GDScript) #112217
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
base: master
Are you sure you want to change the base?
Conversation
Now you can retrieve all cached paths or only those with certain typeHint, pathPrefix, fileNamePrefix or fileExtension (C++/C#/GDScript)
|
Oh i forget the docs, of course! |
|
Thanks for opening a pull request! Feature pull requests should be associated to a feature proposal to justify the need for implementing the feature in Godot core. Please open a proposal on the Godot proposals repository (and link to the proposal in this pull request's body). |
Created it at: godotengine/godot-proposals#13523 |
…ed resources + Updated Documentation with Examples
|
Feature is now finalized Feel free to provide any form of feedback 😊 |
Hey, this is my first PR / contribution to the engine 👋
Description:
This PR extends the
ResourceLoaderclass with a set of new utility methods that allow querying the engine's internalResourceCachefor paths matching specific criteria. No existing logic has been changed, only additions have been madeThis feature is fully available in both C++, GDScript and C#
Knowledge
Any Resource is considered "cached", when one of the following conditions is true:
ResourceLoader.load(...)Use Cases:
Retrieve all cached resource paths where ...
(e.g "Image", "AudioStreamWAV", "AudioStreamMP3", "JSON", "Shader", "VisualShader")(e.g. "Spritesheet_Char01_Idle")(e.g. "Spritesheet_")(e.g. "Char01")(e.g. "user://", "res://", "C:/" )(e.g. "/data", "/settings", "/images")(e.g. "Spritesheet_Char01_Attack.png")(e.g. "Spritesheet_", "IMG_", "Sprite_")(e.g. "Char01")(e.g "mp3", "wav", "ogg", "jpeg", "png", "json")(e.g. "t") --> could match: ( "txt", "tres", "translation" )(e.g. "res") --> could match: ( "tres", "res" )And once you have them, just load them directly from the cache via
ResourceLoader.load(...)Usages On UI:
Results
Note: Retrievals on the "ResourceName" target the "Name" in the inspector

(1) Dictionary Retrieval (formatted via JSON.stringify() )

(2) Array Retrieval (using

p_with_godot_type=trueandseparator=" -> ")(3) Full Documentation with 2 examples per function

How To Test / Use:
C# Test Code:
GDScript Test Code
I hope this helps a lot of your projects out! ✨
Feel free to give me any feedback on the idea, the PR, the description/text of the PR and such