From 00c8d83cbb1ee3986196b14778c7fe00d971bf9f Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Sun, 18 Feb 2024 20:45:33 +0100 Subject: [PATCH] Don't force consumers to do hot reloading --- Cargo.lock | 109 +------------------------------ crates/bevy_plugin/Cargo.toml | 14 +--- crates/bevy_plugin/src/plugin.rs | 14 ++-- 3 files changed, 9 insertions(+), 128 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db207814..1284fc9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -413,7 +413,6 @@ dependencies = [ "futures-io", "futures-lite", "js-sys", - "notify-debouncer-full", "parking_lot 0.12.1", "ron", "serde", @@ -1840,27 +1839,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "file-id" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6584280525fb2059cba3db2c04abf947a1a29a45ddae89f3870f8281704fafc9" -dependencies = [ - "windows-sys 0.48.0", -] - -[[package]] -name = "filetime" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.4.1", - "windows-sys 0.52.0", -] - [[package]] name = "fixed_decimal" version = "0.5.5" @@ -1922,15 +1900,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" -[[package]] -name = "fsevent-sys" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" -dependencies = [ - "libc", -] - [[package]] name = "futures-core" version = "0.3.30" @@ -2009,7 +1978,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0af1827b7dd2f36d740ae804c1b3ea0d64c12533fb61ff91883005143a0e8c5a" dependencies = [ "core-foundation", - "inotify 0.10.2", + "inotify", "io-kit-sys", "js-sys", "libc", @@ -2366,17 +2335,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a" -[[package]] -name = "inotify" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" -dependencies = [ - "bitflags 1.3.2", - "inotify-sys", - "libc", -] - [[package]] name = "inotify" version = "0.10.2" @@ -2528,26 +2486,6 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" -[[package]] -name = "kqueue" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" -dependencies = [ - "kqueue-sys", - "libc", -] - -[[package]] -name = "kqueue-sys" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" -dependencies = [ - "bitflags 1.3.2", - "libc", -] - [[package]] name = "ktx2" version = "0.3.0" @@ -2719,18 +2657,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "mio" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.48.0", -] - [[package]] name = "multimap" version = "0.8.3" @@ -2878,39 +2804,6 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51" -[[package]] -name = "notify" -version = "6.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" -dependencies = [ - "bitflags 2.4.2", - "crossbeam-channel", - "filetime", - "fsevent-sys", - "inotify 0.9.6", - "kqueue", - "libc", - "log", - "mio", - "walkdir", - "windows-sys 0.48.0", -] - -[[package]] -name = "notify-debouncer-full" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f5dab59c348b9b50cf7f261960a20e389feb2713636399cd9082cd4b536154" -dependencies = [ - "crossbeam-channel", - "file-id", - "log", - "notify", - "parking_lot 0.12.1", - "walkdir", -] - [[package]] name = "ntapi" version = "0.4.1" diff --git a/crates/bevy_plugin/Cargo.toml b/crates/bevy_plugin/Cargo.toml index 02bceb6e..7e4c70b6 100644 --- a/crates/bevy_plugin/Cargo.toml +++ b/crates/bevy_plugin/Cargo.toml @@ -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" @@ -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" diff --git a/crates/bevy_plugin/src/plugin.rs b/crates/bevy_plugin/src/plugin.rs index d12933e9..98096a3d 100644 --- a/crates/bevy_plugin/src/plugin.rs +++ b/crates/bevy_plugin/src/plugin.rs @@ -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::().expect(ASSET_ERROR); + let watching_for_changes = asset_server.watching_for_changes(); self.insert_resource(WatchingForChanges(watching_for_changes)) } @@ -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);