What is the best practice to loading content in the background? #228
-
Hi, I just curious about What is the best practice to loading content in the background? Currently, I load 10 files per update() and if accumulated time more than 1 second. It will not continue loading files until accumulated time back to normal. This allows my scene to have a loading animation. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I think the ideal solution is to have assets load on a seperate thread - you can then use something like a The important thing to consider is that I'll try to write up an example of what this could look like, it's something I've been meaning to do for a while! |
Beta Was this translation helpful? Give feedback.
I think the ideal solution is to have assets load on a seperate thread - you can then use something like a
channel
or an atomic to communicate back to the main thread what the progress is.The important thing to consider is that
Context
can't be accessed unless you're on the main thread - so for types likeTexture
which need to accessContext
, you'll need to pass the loaded file back across to the main thread to create your final asset (e.g. viaTexture::from_file_data
).I'll try to write up an example of what this could look like, it's something I've been meaning to do for a while!