-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Asynchronous resource loading #2
Comments
Sounds like a good idea. Gotta conjure up a nice API for this but indeed. Thanks for suggesting this! |
Okay, finally found some time to implement this: @export var one_thousand_images:ResourceGroup
var _background_loader:ResourceGroupBackgroundLoader
func _on_load_button_pressed():
# will start the background loading process
_background_loader = one_thousand_images.load_all_in_background(_on_resource_loaded)
func _on_resource_loaded(info:ResourceGroupBackgroundLoader.ResourceLoadingInfo):
# the callback gives you an info object which has the overall progress (0 - 1)
_progress_bar.value = info.progress * 100.0
# the path of the resource and a success flag
_info_label.text = info.path + " : " + ("OK" if info.success else "NOT OK")
# a flag if this is the last resource
_done_label.visible = info.last
if info.success:
# and the resource itself (if successful)
var resource = info.resource
# do something with the resource here.
func _on_cancel_button_pressed():
# cancels the background loading. it is guaranteed that your callback will no longer
# be called once this returns
_background_loader.cancel() 2024-01-31_08-30-14.mp4Would this API work for you? |
Yes, this looks fantastic. Thank you for taking the time to implement this! :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Are there any plans to implement asynchronous resource loading as a feature? I was looking through the code of the plugin and noticed that it uses Godot's simplified
load()
function to load resources from disk. This is fine if you're loading only small amounts of assets, but this will be a huge issue if you have to load a ton of assets, asload()
is synchronous and will cause the game to become unresponsive if you have to load a ton of stuff. (https://docs.godotengine.org/en/stable/tutorials/io/background_loading.html#background-loading)I think it would be nice to have the option to asynchronously load assets from your resource groups, and maybe allow the ability to register a
Callable
that can listen for when loading completes or fails for each loaded asset. It would definitely greatly improve the performance of games that have to load a ton on assets. Godot has theResourceLoader
static class that can aid in achieving this. (https://docs.godotengine.org/en/stable/classes/class_resourceloader.html#class-resourceloader-method-load). The two methods this class has that can do asynchronous loading isResourceLoader.load_threaded_request()
andResourceLoader.load_threaded_get()
So yeah, just a suggestion. This feature would really help my game because my game will have a ton of items that need to be loaded. This plugin is really nice because it allows me to group together all my item into groups and makes loading them super easy. The only issue so far is the lack of support for loading assets asynchronously.
The text was updated successfully, but these errors were encountered: