Skip to content

Commit

Permalink
Don't force consumers to do hot reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
janhohenheim committed Feb 18, 2024
1 parent 83be515 commit 00c8d83
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 128 deletions.
109 changes: 1 addition & 108 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 2 additions & 12 deletions crates/bevy_plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ sha2 = "0.10"
rand = { version = "0.8", features = ["small_rng"] }


[target.'cfg(any(target_arch = "wasm32", target_os = "android"))'.dependencies.bevy]
[dependencies.bevy]
version = "0.13"
default-features = false
features = ["bevy_asset", "serialize"]
features = ["bevy_asset", "multi-threaded"]

[dev-dependencies]
tempfile = "3"
Expand All @@ -38,18 +38,8 @@ version = "0.13.0"
default-features = false
features = [
"bevy_core_pipeline",
"bevy_render",
"bevy_winit",
"file_watcher",
"x11",
"bevy_audio",
"multi-threaded",
]

[target.'cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))'.dependencies.bevy]
version = "0.13"
default-features = false
features = ["bevy_asset", "serialize", "file_watcher",]

[target.'cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))'.dependencies]
glob = "0.3.1"
14 changes: 6 additions & 8 deletions crates/bevy_plugin/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,9 @@ impl YarnApp for App {
}

fn register_watching_for_changes(&mut self) -> &mut Self {
let on_by_default = cfg!(all(not(target_arch = "wasm32"), not(target_os = "android")));

let asset_plugin = get_asset_plugin(self);
let watching_for_changes = asset_plugin
.watch_for_changes_override
.unwrap_or(on_by_default);
let asset_server = self.world.get_resource::<AssetServer>().expect(ASSET_ERROR);

let watching_for_changes = asset_server.watching_for_changes();
self.insert_resource(WatchingForChanges(watching_for_changes))
}

Expand All @@ -256,9 +252,11 @@ impl YarnApp for App {

fn get_asset_plugin(app: &App) -> &AssetPlugin {
let asset_plugins: Vec<&AssetPlugin> = app.get_added_plugins();
asset_plugins.into_iter().next().expect("Yarn Spinner requires access to the Bevy asset plugin. \
Please add `YarnSpinnerPlugin` after `AssetPlugin`, which is commonly added as part of the `DefaultPlugins`")
asset_plugins.into_iter().next().expect(ASSET_ERROR)
}

const ASSET_ERROR: &str = "Yarn Spinner requires access to the Bevy asset plugin. \
Please add `YarnSpinnerPlugin` after `AssetPlugin`, which is commonly added as part of the `DefaultPlugins`";

#[derive(Debug, Clone, PartialEq, Eq, Hash, Resource)]
pub(crate) struct AssetRoot(pub(crate) PathBuf);

0 comments on commit 00c8d83

Please sign in to comment.