Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Hot Reloading Issue #52

Merged
merged 1 commit into from
Nov 25, 2024
Merged

fix: Hot Reloading Issue #52

merged 1 commit into from
Nov 25, 2024

Conversation

shekohex
Copy link
Contributor

Overview

While trying this awesome plugin and trying it out for the first time, I've noticed that whenever I change something in tiled, it does not hot-reload it in my game, even though I get this in my logs:

2024-11-24T20:42:16.878905Z  INFO bevy_ecs_tiled: Map 'maps/desert/desert.tmx' has finished loading, spawn it
2024-11-24T20:42:26.824795Z  INFO bevy_asset::server: Reloading maps\desert\desert.tmx because it has changed
...
2024-11-24T20:42:26.889222Z  INFO bevy_ecs_tiled: Map changed: AssetId<bevy_ecs_tiled::asset::TiledMap>{ index: 0, generation: 0}    

But nothing actually happens. Turns out that the query for the changed map, never return anything, or basically it does not match on anything.

After applying this fix, it now works and when I change something it tiled, it hot reloads it in my game.

...
2024-11-24T20:42:38.873064Z  INFO bevy_ecs_tiled: Map changed: AssetId<bevy_ecs_tiled::asset::TiledMap>{ index: 0, generation: 0}
2024-11-24T20:42:38.905235Z  INFO bevy_ecs_tiled: Map 'maps/desert/desert.tmx' has finished loading, spawn it

Changes

This pull request includes changes to the src/lib.rs file to update the handling of map events and improve code readability. The most important changes involve modifying the type used for map handles and updating the corresponding method calls.

Changes to map handle type:

  • src/lib.rs: Updated the map_query parameter in fn handle_map_events to use TiledMapHandle instead of Handle<TiledMap>.
  • src/lib.rs: Updated the map_query parameter in fn remove_map_by_asset_id to use TiledMapHandle instead of Handle<TiledMap>.

Method call updates:

  • src/lib.rs: Modified the method call from map_handle.id() to map_handle.0.id() in fn handle_map_events.
  • src/lib.rs: Modified the method call from map_handle.id() to map_handle.0.id() in fn remove_map_by_asset_id.

@adrien-bon
Copy link
Owner

Hi!

Thanks for the high qualtiy PR!

I did the same kind of changes on the Bevy 0.15 branch but I did not realize that not having these actually broke hot-reload. I will release a fixed version with you fix.

Again, thanks for your contribution 👍

@adrien-bon adrien-bon merged commit b1a53c8 into adrien-bon:main Nov 25, 2024
5 checks passed
adrien-bon added a commit that referenced this pull request Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants