Update loading in a thread demo for 4.0 #747
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates and improves the simple background loading demo (the one that doesn't use
load_interactive
). On the list in #697.In addition to updating for 4.0, I made the following additional changes:
return tex
that just says it returns something, or the one that saysResourceLoader.load
loads a resource). Most of them I kept and just edited for clarity.Thread
objects. According to the documentation, you shouldn't do this, so the demo now waits for the previous thread to finish (if there is one) and makes a new one._exit_tree
method that makes sure the thread is finished, then frees it._on_load_pressed
,_bg_load
,_bg_load_done
,_exit_tree
.Some of these changes are subjective, so let me know what you think. The last one is technically in violation of the GDScript style guide, since it puts a built-in virtual method after the private methods, but I think it improves readability enough to be worth it. I'm also not sure why the documentation says not to reuse thread objects, since doing so seems to work just fine.