You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use a resource and a system to check when the images is fully loaded, then I apply the transformation. However, I also need to delay the creation of the material because it only accept the image after being modified. Which means I also need to delay the spawning of all meshes using this material. This is obviously not the way to go. I don't like either to always watch for asset event with a mutable access to image assets.
fnasset_watcher(/* ... */){for&event in events.read(){ifletAssetEvent::LoadedWithDependencies{ id } = event {if blocks_assets.textures.id() == id {let textures = images.get_mut(id).unwrap();
textures.sampler = ImageSampler::nearest();
textures.reinterpret_stacked_2d_as_array(2);// spawning my mesh ...}}}}
I see it is possible to define a custom asset with its corresponding loader. But this is not suiting me, as I still want to load a png image, and I still need a Handle<Image> in my material.
I see it is possible to define a custom asset transform. Which would be perfect for my need, except I have no idea how to apply it when loading my image. It seems it only works with custom asset, but as I said before, this doesn't suit my need.
I am sure, what I try to do is a very common pattern that must have a easy solution in Bevy, but I just can't find it.
How to process certain images when loaded but before being available?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
For a custom material, I need a
2d_array
image, but for that I need to call thereinterpret_stacked_2d_as_array
method on theImage
struct.I use a resource and a system to check when the images is fully loaded, then I apply the transformation. However, I also need to delay the creation of the material because it only accept the image after being modified. Which means I also need to delay the spawning of all meshes using this material. This is obviously not the way to go. I don't like either to always watch for asset event with a mutable access to image assets.
I see it is possible to define a custom asset with its corresponding loader. But this is not suiting me, as I still want to load a png image, and I still need a
Handle<Image>
in my material.I see it is possible to define a custom asset transform. Which would be perfect for my need, except I have no idea how to apply it when loading my image. It seems it only works with custom asset, but as I said before, this doesn't suit my need.
I am sure, what I try to do is a very common pattern that must have a easy solution in Bevy, but I just can't find it.
How to process certain images when loaded but before being available?
Beta Was this translation helpful? Give feedback.
All reactions