bevy_ecs_tilemap
bevy_ecs_tilemap copied to clipboard
Hot reloading tilesets
Using bevy_ecs_tilemap 0.5
I seem to remember when working with bevy_ecs_tilemap pre-0.5, updating a tileset asset with asset_server.watch_for_changes()
on would automatically update the rendered tilemaps in game. This doesn't seem to be working anymore. Might be on my end? Also I might be misremembering. I imagine the chunking and custom rendering stuff going on could complicate hot reloading.
I wasn't about to reproduce this. I did need to add the watch for changes setting to get it to work however though.
Maybe it's a difference between our systems? I'm on linux.
I'm also now testing this on bevy_ecs_tilemap main, not 0.5.
I've been able to reproduce this with the map example. My minor edits are on my fork's branch issue_172
https://github.com/Trouv/bevy_ecs_tilemap/tree/issue_172
I didn't change much:
- turned on watch for changes
- made it so the
set_texture_filters_to_nearest
system works onAssetEvent::Modified
as well
I've tried setting watch_for_changes via AssetServer::watch_for_changes()
and AssetServerSettings::watch_for_changes
, both separately and together.
Then, while the example is running I just hit it with $ cp assets/tiles2.png assets/tiles.png
. No hot reloading.
Bevy's filesystem_watcher
feature should be enabled since the dev-dependencies don't turn off default-features.
Accidentally closed this, sorry
Maybe it's a difference between our systems? I'm on linux.
I'm also now testing this on bevy_ecs_tilemap main, not 0.5.
I've been able to reproduce this with the map example. My minor edits are on my fork's branch
issue_172
https://github.com/Trouv/bevy_ecs_tilemap/tree/issue_172I didn't change much:
- turned on watch for changes
- made it so the
set_texture_filters_to_nearest
system works onAssetEvent::Modified
as wellI've tried setting watch_for_changes via
AssetServer::watch_for_changes()
andAssetServerSettings::watch_for_changes
, both separately and together.Then, while the example is running I just hit it with
$ cp assets/tiles2.png assets/tiles.png
. No hot reloading.Bevy's
filesystem_watcher
feature should be enabled since the dev-dependencies don't turn off default-features.
This seems to be an issue on linux, I can't reproduce any of this on windows. 🤔
The story gets stranger..
I went ahead and tried it on my windows partition and it didn't work there either?? Maybe it's just me??
I could maybe maybe see it being a hardware issue. In which case I should mention that my gpu is an Nvidia GTX 1060. It's weird that hot reloading would work fine for me when it comes to sprites and sprite sheets though.
Can confirm this. linux, amd gpu, mesa drivers.
Cannot hot reload tile assets (they simply disappear completely, when I change them at runtime), but reloading works fine for all other sprites.
Same as nerdachse here.
Sometimes when a texture is reloaded this warning comes up:
WARN bevy_asset::asset_server: encountered an error while loading an asset: Error reading image file textures/my_texture.png: failed to load an image: Format error decoding Png: unexpected EOF, this is an error in `bevy_render`.
Maybe this helps.
This doesn't happen when I move/copy a file like Trouv explained, but only when I hit save in GIMP.
But however I initiate a reload, tile assets disappear while other sprites reload as expected.
Same as nerdachse here. Sometimes when a texture is reloaded this warning comes up:
WARN bevy_asset::asset_server: encountered an error while loading an asset: Error reading image file textures/my_texture.png: failed to load an image: Format error decoding Png: unexpected EOF, this is an error in `bevy_render`.
Maybe this helps. This doesn't happen when I move/copy a file like Trouv explained, but only when I hit save in GIMP. But however I initiate a reload, tile assets disappear while other sprites reload as expected.
This sounds like a bug with bevy.
For what it's worth, hot reloading works totally fine for me with Bevy 0.7, LDtk 1.0, and bevy_ecs_ldtk
on Linux Pop_OS! ( Ubuntu ) 20.04. :man_shrugging:
Just to add to this: Hot-reloading is not working for me also. It is working for "normal" sprites though.
Manjaro up-to-date, bevy 0.8.1, bevy_ecs_tilemap taken from main-branch. Any ideas where I could/should look for a solution/fix?
I don't have time to really delve into it right now, but as a quick tip, if you use a path
dependency in your Cargo.toml to depend on a locally cloned bevy_ecs_tilemap
repo, you might try sticking println!
here to see if the asset change is being detected at all.
That would give us some more direction on what might be causing it.
Note: Technically there's already a log call right there, so you might be able to run the game with
RUST_LOG=info
to see the message. I'm not sure, because it uses thelog
crate and the tracing macros that come with Bevy. I'm not sure if Bevy is setup to forward messages from thelog
crate.
Checked it. Changes to the map (map.tmx) are reflected immediately and I can log that the AssetEvents are triggered.
Changes to the TileSet (tiles.png in this case) are not doing anything at all.
In my own project I tested that the AssetEvent<Handle< Image >> are actually send, but I assume the cached textures are not correctly updated.
Ah OK. I'm not 100% sure if I ever tested updating the tilemap texture or not, so when I thought it was working for me I might have been wrong.
Without going deeper into the code I don't have any further suggestions on what to look at unfortunately, and I'm short for time at the moment so that's probably as far as I can try to help for now.
It sounds like we either need extra code in bevy_ecs_tilemap
to handle refreshing the textures or something, or it's a driver/system. I don't think it's a Bevy issue, but still can't rule it out for sure without going deeper.
As there was no commit to #273 since my last comment, hot reloading of tilesets is still broken for me.
I just checked again to be sure: I checked out the main branch including the helpers overhaul.
I tested the tiled example:
- changes to map.tmx are registered at runtime (changing the tile data and funnily changing the image source both work; i.e. switching between tiles.png and tiles2.png)
- but changing the source image itself (tiles.png) does not do anything. A restart is needed to get the image to update.
Could someone please mark this issue as not resolved?
I just tested again: This is still broken while using TextureAtlas or while using Vec<Handle<Image>> as a TilemapTexture.
Yep, still broken for me as well. Tested with Bevy 0.9 and main branch (f01e8142).
--- a/examples/basic.rs
+++ b/examples/basic.rs
@@ -111,7 +111,7 @@ fn main() {
..Default::default()
},
..default()
- }).set(ImagePlugin::default_nearest()))
+ }).set(ImagePlugin::default_nearest()).set(AssetPlugin { watch_for_changes: true, ..default() }))
.add_plugin(TilemapPlugin)
.add_startup_system(startup)
.add_system(helpers::camera::movement)
Then I ran it and tried editing the tileset, but didn't see the changes before I quit and relaunched the the example.
This problem is still happening to me on my Linux machine, too.
bevy = "0.10"
Possible fix PR: #431.
i have the same issue. hot reloading not working on mac os.