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

Update development branch to Bevy 0.11-dev #132

Merged
merged 28 commits into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cdf5c6c
Update checkout and cache actions
NiklasEi Feb 28, 2023
867f90f
Merge pull request #106 from NiklasEi/bevy_main
NiklasEi Mar 10, 2023
cec54fb
Compare paths instead of strings
NiklasEi Mar 16, 2023
050dad8
Merge pull request #112 from NiklasEi/fix_full_collection_example_on_…
NiklasEi Mar 16, 2023
d0c862b
Use .track_progress() in iyes_progress example
johanhelsing Mar 23, 2023
84eb35c
Merge pull request #115 from johanhelsing/progress-system
NiklasEi Mar 24, 2023
5de374f
Remove features for optional dependencies and bump bevy_common_assets
NiklasEi Mar 24, 2023
38a0e4a
Merge pull request #117 from NiklasEi/remove_features_for_optional_de…
NiklasEi Mar 25, 2023
e60e73f
Mention asset unloading in the readme (#114)
NiklasEi Mar 31, 2023
15048c6
Merge pull request #119 from NiklasEi/mention_asset_unloading
NiklasEi Apr 1, 2023
4a0e5a4
Bump to version 0.16.0
NiklasEi Apr 1, 2023
5cd9067
Bump to development version 0.17.0
NiklasEi Apr 1, 2023
e14fca5
Allow usage in multiple states
NiklasEi Apr 11, 2023
52dfef9
Merge pull request #127 from NiklasEi/allow_usage_in_multiple_states
NiklasEi Apr 12, 2023
dd12499
Mention adding the default plugins before configuring a loading state…
NiklasEi Apr 12, 2023
e472851
Allow reloading of dynamic asset files
NiklasEi Apr 12, 2023
bcab9b2
Merge pull request #130 from NiklasEi/add_asset_server_before_loading…
NiklasEi Apr 13, 2023
0acd104
Merge pull request #129 from NiklasEi/reload_dynamic_asset_collections
NiklasEi Apr 13, 2023
ba8aff6
Workaround for correct scheduling with non default exit criteria
NiklasEi Apr 14, 2023
c71df8b
Merge pull request #131 from NiklasEi/fix_crash_with_non_default_exit…
NiklasEi Apr 14, 2023
95d9795
Update to Bevy 0.11-dev
eerii Apr 15, 2023
3a2aa89
Fix tests and lint
eerii Apr 16, 2023
733c607
Update actions on GitHub Actions workflows
striezel Apr 20, 2023
ae9e3be
Merge pull request #133 from striezel-stash/ci-actions-update
NiklasEi Apr 22, 2023
d6fca09
Replace unmaintained actions-rs/toolchain action in CI workflows
striezel Apr 22, 2023
b9e4342
Merge pull request #134 from striezel-stash/actions-rs-toolchain-repl…
NiklasEi Apr 22, 2023
26a979c
Merge branch 'main' into bevy_main
eerii Apr 24, 2023
16922f8
Add again loading set and fix example
eerii Apr 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
Expand All @@ -21,10 +21,9 @@ jobs:
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-build-stable-${{ hashFiles('**/Cargo.toml') }}
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
override: true
- uses: taiki-e/install-action@v1
with:
tool: cargo-hack
Expand All @@ -41,8 +40,8 @@ jobs:
os: [ windows-latest, ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
Expand All @@ -51,10 +50,9 @@ jobs:
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-build-stable-${{ hashFiles('**/Cargo.toml') }}
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
override: true
- uses: taiki-e/install-action@v1
with:
tool: cargo-hack
Expand All @@ -66,8 +64,8 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
Expand All @@ -76,11 +74,10 @@ jobs:
~/.cargo/git/db/
target/
key: ubuntu-latest-cargo-build-stable-${{ hashFiles('**/Cargo.toml') }}
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy
override: true
- name: Install alsa and udev
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
- name: Run clippy
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

- Fix running loading states in parallel states, meaning using multiple state types (resolves [#125](https://github.com/NiklasEi/bevy_asset_loader/issues/125))
- Dynamic asset files can be loaded multiple times now
- This allows re-entering a loading state containing dynamic assets (see [#126](https://github.com/NiklasEi/bevy_asset_loader/issues/126))
- and loading dynamic assets in multiple states (see [#123](https://github.com/NiklasEi/bevy_asset_loader/issues/123))
- Fix crash with non default exit criteria (see [#121](https://github.com/NiklasEi/bevy_asset_loader/issues/121))

## v0.16.0
- Remove features coming from optional dependencies

## v0.15.0
- Option to load folders as maps of path to handle (resolves [#32](https://github.com/NiklasEi/bevy_asset_loader/issues/32))
- Changed the default file ending for standard dynamic asset files from `.assets` to `.assets.ron`
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ use bevy_asset_loader::prelude::*;
fn main() {
App::new()
.add_state::<GameState>()
.add_plugins(DefaultPlugins)
.add_loading_state(
LoadingState::new(GameState::AssetLoading)
.continue_to_state(GameState::Next)
)
.add_collection_to_loading_state::<_, MyAssets>(GameState::AssetLoading)
.add_plugins(DefaultPlugins)
.add_system(use_my_assets.in_schedule(OnEnter(GameState::Next)))
.add_systems(OnEnter(GameState::Next), use_my_assets)
.run();
}

Expand Down Expand Up @@ -111,6 +111,8 @@ Dynamic assets can be optional. This requires the derive attribute `optional` on

The example [full_dynamic_collection](/bevy_asset_loader/examples/full_dynamic_collection.rs) shows all supported field types for dynamic assets.

Note that adding a dynamic asset file to a loading state requires the `AssetServer` resource to be available. In most cases that means that you should add the `DefaultPlugins` before configuring your loading state.

### Custom dynamic assets

You can define your own types to load as dynamic assets. Take a look at the [custom_dynamic_assets.rs](/bevy_asset_loader/examples/custom_dynamic_assets.rs) example for some code.
Expand Down Expand Up @@ -402,14 +404,18 @@ struct MyAssets {
}
```

## Unloading assets

Bevy unloads an asset when there are no strong asset handles left pointing to the asset. An `AssetCollection` stores strong handles and ensures that assets contained in it are not removed from memory. If you want to unload assets, you need to remove any `AssetCollection` resource that holds handles pointing to those assets. You, for example, could do this when leaving the state that needed the collection.

## Compatible Bevy versions

The main branch is compatible with the latest Bevy release, while the branch `bevy_main` tries to track the `main` branch of Bevy (PRs updating the tracked commit are welcome).

Compatibility of `bevy_asset_loader` versions:
| `bevy_asset_loader` | `bevy` |
| :-- | :-- |
| `0.15` | `0.10` |
| `0.15` - `0.16` | `0.10` |
| `0.14` | `0.9` |
| `0.12` - `0.13` | `0.8` |
| `0.10` - `0.11` | `0.7` |
Expand Down
20 changes: 10 additions & 10 deletions bevy_asset_loader/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_asset_loader"
version = "0.15.0"
version = "0.17.0-dev"
authors = ["Niklas Eicker <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand All @@ -16,23 +16,23 @@ readme = "README.md"
2d = ["bevy/bevy_sprite", "bevy_asset_loader_derive/2d"]
# This feature adds support for bevy's StandardMaterial assets
3d = ["bevy/bevy_pbr", "bevy/bevy_render", "bevy_asset_loader_derive/3d"]
standard_dynamic_assets = ["bevy_common_assets", "serde"]
progress_tracking = ["iyes_progress"]
standard_dynamic_assets = ["dep:bevy_common_assets", "dep:serde"]
progress_tracking = ["dep:iyes_progress"]

[dependencies]
bevy = { version = "0.10", default-features = false, features = ["bevy_asset"] }
bevy_asset_loader_derive = { version = "=0.15.0", path = "../bevy_asset_loader_derive" }
bevy = { git = "https://github.com/bevyengine/bevy", default-features = false, features = ["bevy_asset"] }
bevy_asset_loader_derive = { version = "=0.17.0-dev", path = "../bevy_asset_loader_derive" }
anyhow = "1"

bevy_common_assets = { version = "0.5.0", features = ["ron"], optional = true }
bevy_common_assets = { git = "https://github.com/NiklasEi/bevy_common_assets", branch = "bevy_main", features = ["ron"], optional = true }
serde = { version = "1", optional = true }
iyes_progress = { version = "0.8", optional = true }
iyes_progress = { git = "https://github.com/josekoalas/iyes_progress", branch = "bevy_main", optional = true }

[dev-dependencies]
bevy = { version = "0.10", features = ["vorbis"] }
bevy = { git = "https://github.com/bevyengine/bevy", features = ["vorbis"] }
anyhow = "1"
iyes_progress = { version = "0.8" }
bevy_common_assets = { version = "0.5.0", features = ["ron"] }
iyes_progress = { git = "https://github.com/josekoalas/iyes_progress", branch = "bevy_main" }
bevy_common_assets = { git = "https://github.com/NiklasEi/bevy_common_assets", branch = "bevy_main", features = ["ron"] }
serde = { version = "1" }
trybuild = { version = "1.0" }

Expand Down
9 changes: 6 additions & 3 deletions bevy_asset_loader/examples/atlas_from_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ use bevy_asset_loader::prelude::*;
fn main() {
App::new()
.add_state::<MyStates>()
.add_plugins(DefaultPlugins)
.add_loading_state(
LoadingState::new(MyStates::AssetLoading).continue_to_state(MyStates::Next),
)
.add_collection_to_loading_state::<_, MyAssets>(MyStates::AssetLoading)
.insert_resource(Msaa::Off)
.add_plugins(DefaultPlugins)
.add_system(draw_atlas.in_schedule(OnEnter(MyStates::Next)))
.add_system(animate_sprite_system.run_if(in_state(MyStates::Next)))
.add_systems(OnEnter(MyStates::Next), draw_atlas)
.add_systems(
Update,
animate_sprite_system.run_if(in_state(MyStates::Next)),
)
.run();
}

Expand Down
2 changes: 1 addition & 1 deletion bevy_asset_loader/examples/custom_dynamic_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {
"custom.my-assets.ron",
)
.add_collection_to_loading_state::<_, MyAssets>(MyStates::AssetLoading)
.add_system(render_stuff.in_schedule(OnEnter(MyStates::Next)))
.add_systems(OnEnter(MyStates::Next), render_stuff)
.run();
}

Expand Down
8 changes: 6 additions & 2 deletions bevy_asset_loader/examples/dynamic_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ fn main() {
.add_collection_to_loading_state::<_, AudioAssets>(MyStates::AssetLoading)
.insert_resource(Msaa::Off)
.add_systems(
(spawn_player_and_tree, play_background_audio).in_schedule(OnEnter(MyStates::Next)),
OnEnter(MyStates::Next),
(spawn_player_and_tree, play_background_audio),
)
.add_systems(
Update,
animate_sprite_system.run_if(in_state(MyStates::Next)),
)
.add_system(animate_sprite_system.run_if(in_state(MyStates::Next)))
.run();
}

Expand Down
6 changes: 3 additions & 3 deletions bevy_asset_loader/examples/failure_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ fn main() {
.on_failure_continue_to_state(MyStates::ErrorScreen),
)
.add_collection_to_loading_state::<_, MyAssets>(MyStates::AssetLoading)
.add_system(timeout.run_if(in_state(MyStates::AssetLoading)))
.add_system(fail.in_schedule(OnEnter(MyStates::Next)))
.add_system(ok.in_schedule(OnEnter(MyStates::ErrorScreen)))
.add_systems(Update, timeout.run_if(in_state(MyStates::AssetLoading)))
.add_systems(OnEnter(MyStates::Next), fail)
.add_systems(OnEnter(MyStates::ErrorScreen), ok)
.run();
}

Expand Down
21 changes: 6 additions & 15 deletions bevy_asset_loader/examples/full_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use bevy::asset::LoadState;
use bevy::prelude::*;
use bevy::utils::HashMap;
use bevy_asset_loader::prelude::*;
use std::path::Path;

fn main() {
App::new()
Expand All @@ -12,7 +13,7 @@ fn main() {
LoadingState::new(MyStates::AssetLoading).continue_to_state(MyStates::Next),
)
.add_collection_to_loading_state::<_, MyAssets>(MyStates::AssetLoading)
.add_system(expectations.in_schedule(OnEnter(MyStates::Next)))
.add_systems(OnEnter(MyStates::Next), expectations)
.run();
}

Expand Down Expand Up @@ -166,13 +167,8 @@ fn expectations(
LoadState::Loaded
);
assert_eq!(
name,
asset_server
.get_handle_path(handle.clone())
.unwrap()
.path()
.to_str()
.unwrap()
Path::new(name),
asset_server.get_handle_path(handle.clone()).unwrap().path()
);
}
assert_eq!(assets.mapped_files_typed.len(), 2);
Expand All @@ -182,13 +178,8 @@ fn expectations(
LoadState::Loaded
);
assert_eq!(
name,
asset_server
.get_handle_path(handle.clone())
.unwrap()
.path()
.to_str()
.unwrap()
Path::new(name),
asset_server.get_handle_path(handle.clone()).unwrap().path()
);
}

Expand Down
2 changes: 1 addition & 1 deletion bevy_asset_loader/examples/full_dynamic_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() {
"full_dynamic_collection.assets.ron",
)
.add_collection_to_loading_state::<_, MyAssets>(MyStates::AssetLoading)
.add_system(expectations.run_if(in_state(MyStates::Next)))
.add_systems(Update, expectations.run_if(in_state(MyStates::Next)))
.run();
}

Expand Down
4 changes: 2 additions & 2 deletions bevy_asset_loader/examples/init_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use bevy_asset_loader::prelude::*;
/// them by adding up their pixel data.
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_state::<MyStates>()
.add_loading_state(
LoadingState::new(MyStates::AssetLoading).continue_to_state(MyStates::Next),
)
.add_collection_to_loading_state::<_, ImageAssets>(MyStates::AssetLoading)
.init_resource_after_loading_state::<_, CombinedImage>(MyStates::AssetLoading)
.insert_resource(Msaa::Off)
.add_plugins(DefaultPlugins)
.add_system(draw.in_schedule(OnEnter(MyStates::Next)))
.add_systems(OnEnter(MyStates::Next), draw)
.run();
}

Expand Down
23 changes: 16 additions & 7 deletions bevy_asset_loader/examples/manual_dynamic_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@ fn main() {
.insert_resource(Msaa::Off)
.insert_resource(ShowBackground(false))
.add_systems(
(spawn_player_and_tree, play_background_audio).in_schedule(OnEnter(MyStates::Next)),
OnEnter(MyStates::Next),
(
spawn_player_and_tree,
play_background_audio,
render_optional_background,
),
)
.add_systems(OnEnter(MyStates::Menu), menu)
.add_systems(OnExit(MyStates::Menu), exit_menu)
.add_systems(
Update,
(
character_setup.run_if(in_state(MyStates::Menu)),
update_menu.run_if(in_state(MyStates::Menu)),
move_player.run_if(in_state(MyStates::Next)),
),
)
.add_system(menu.in_schedule(OnEnter(MyStates::Menu)))
.add_system(character_setup.run_if(in_state(MyStates::Menu)))
.add_system(update_menu.run_if(in_state(MyStates::Menu)))
.add_system(exit_menu.in_schedule(OnExit(MyStates::Menu)))
.add_system(render_optional_background.in_schedule(OnEnter(MyStates::Next)))
.add_system(move_player.run_if(in_state(MyStates::Next)))
.run();
}

Expand Down
4 changes: 2 additions & 2 deletions bevy_asset_loader/examples/no_loading_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ fn main() {
// This requires the extension trait `AssetCollectionApp` to be in scope.
.init_collection::<ImageAssets>()
// This system listens for mouse clicks and then loads + inserts the AudioAssets collection
.add_system(load_and_play_audio)
.add_system(draw.on_startup())
.add_systems(Startup, draw)
.add_systems(Update, load_and_play_audio)
.run();
}

Expand Down
Loading