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

Error when using progress_tracking and progress_tracking_stageless features #72

Closed
arewerage opened this issue Jul 21, 2022 · 7 comments

Comments

@arewerage
Copy link
Contributor

When trying to delay the end of loading assets using iyes_progress, an error occurs:

thread 'main' panicked at 'State Transiton Stage not found (assuming auto-added label)', C:\Users\Anton\.cargo\registry\src\github.com-1ecc6299db9ec823\iyes_loopless-0.5.1\src\state.rs:239:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\bevy_template.exe` (exit code: 101)

bevy: 0.7
bevy_asset_loader: branch main

Cargo.toml:

[features]
default = [
    # https://github.com/bevyengine/bevy/blob/main/docs/cargo_features.md
    "bevy/bevy_winit",
    "bevy/render",
    "bevy/png",

    "bevy_asset_loader/2d",
    "bevy_asset_loader/dynamic_assets",
    "bevy_asset_loader/stageless",
    "bevy_asset_loader/progress_tracking",
    "bevy_asset_loader/progress_tracking_stageless",
]

dev = [
    "bevy/dynamic",
]

[dependencies]
bevy = { version = "0.7", default-features = false }
iyes_loopless = { git = "https://github.com/NiklasEi/iyes_loopless", branch = "loopless-schedule-ext-trait" }
bevy-inspector-egui = "0.11.0"
bevy_asset_loader = { git = "https://github.com/NiklasEi/bevy_asset_loader", branch = "main" }
iyes_progress = "0.3.0"

lib.rs:

mod loading;

use bevy::prelude::*;
use iyes_loopless::prelude::*;

pub struct GamePlugin;

impl Plugin for GamePlugin {
    fn build(&self, app: &mut App) {
        app.add_loopless_state(GameState::Loading)
            .add_plugin(loading::LoadingPlugin);
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum GameState {
    Loading,
    MainMenu,
    Gameplay,
}

loading.rs:

use bevy::prelude::*;
use bevy_asset_loader::prelude::*;
use iyes_loopless::prelude::*;
use iyes_progress::{ProgressCounter, ProgressPlugin};

use crate::GameState;

const TIME_FOR_SPLASH_SCREEN: f64 = 5.0;

pub struct LoadingPlugin;

impl Plugin for LoadingPlugin {
    fn build(&self, app: &mut App) {
        app.add_loading_state(
            LoadingState::new(GameState::Loading)
                .continue_to_state(GameState::MainMenu)
                .with_dynamic_collections::<StandardDynamicAssetCollection>(vec!["dynamic.assets"])
                .with_collection::<ImageAssets>()
                .with_collection::<AudioAssets>()
                .with_collection::<FontAssets>(),
        )
        .add_plugin(ProgressPlugin::new(GameState::Loading))
        .add_system(make_loading_delay.run_in_state(GameState::Loading));
    }
}

#[derive(AssetCollection)]
struct ImageAssets {}

#[derive(AssetCollection)]
struct AudioAssets {}

#[derive(AssetCollection)]
struct FontAssets {}

fn make_loading_delay(time: Res<Time>, progress: Res<ProgressCounter>) {
    let condition = time.seconds_since_startup() > TIME_FOR_SPLASH_SCREEN;
    progress.manually_track(condition.into());
}

@arewerage arewerage changed the title Error when using progress_tracking and progress_tracking_stageless features Error when using progress_tracking and progress_tracking_stageless features Jul 21, 2022
@NiklasEi
Copy link
Owner

Are you adding the GamePlugin before the LoadingPlugin? The stageless state needs to be configured before the loading state.

@arewerage
Copy link
Contributor Author

main.rs:

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use bevy::prelude::{default, App, ClearColor, Color, DefaultPlugins, WindowDescriptor};
use bevy_template::GamePlugin;

fn main() {
    App::new()
        .insert_resource(ClearColor(Color::GRAY))
        .insert_resource(WindowDescriptor {
            title: "Bevy Template".to_string(),
            width: 1280.0,
            height: 720.0,
            ..default()
        })
        .add_plugins(DefaultPlugins)
        .add_plugin(GamePlugin)
        .run();
}

@NiklasEi
Copy link
Owner

NiklasEi commented Jul 22, 2022

Sorry, I missed the add_plugin in the GamePlugin. This looks Ok.

@NiklasEi
Copy link
Owner

NiklasEi commented Jul 22, 2022

Does the stageless_progress example run for you?

Is your project code available somewhere (if not I can work with the code blocks above)? I won't be back at my computer for a while, but when I am, I'll take a closer look.

@arewerage
Copy link
Contributor Author

In the next couple of hours I will publish the latest version of the project on github and give a link.

And also check the work of stageless_progress

@NiklasEi
Copy link
Owner

I realized what the issue was and quickly fixed it. The progress feature was pulling in a different version of iyes_loopless, so the stage-label types didn't match anymore. Please use a git dependency for iyes_progress like on main now and run a cargo update.

@arewerage
Copy link
Contributor Author

Thank you very much)

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

No branches or pull requests

2 participants