Replies: 1 comment 14 replies
-
I may be misunderstanding your question, but handles and the asset server are inexpensively cloneable:
|
Beta Was this translation helpful? Give feedback.
14 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have an async task which is used for terrain generation. The task generates new terrain patches as the player moves around the world, allowing for worlds of unbounded size.
The terrain generator depends on an asset that contains data used during the generation process. This asset only needs to be loaded once at startup, and remains resident in memory for the life of the program.
I'm having trouble figuring out how to code this. If I store the asset handle in a resource, the borrow checker complains when I try to use the handle inside the closure for the task.
Also, I would like the task closure to be able to wait until the asset is loaded, but there seems to be no way to
await
for an asset. An alternative is to delay spawning the task until the asset is loaded, but that makes the logic more complex and doesn't generalize to other use cases very well. (In the future I might need more assets inside of tasks, and having to delay spawning the task until all those assets are loaded makes the code very complicated. It's simpler to just await for each loadable resource.)Can anyone provide me with a code example showing how to do this?
Beta Was this translation helpful? Give feedback.
All reactions