bevy
bevy copied to clipboard
State API should panic when missing `StatePlugin`
Bevy version
0.14
What you did
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(MinimalPlugins)
.init_state::<AppState>()
.run();
}
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Hash, States)]
struct AppState;
What went wrong
Crashes inside init_state on an unwrap that assumed a resource would be available from the plugin.
The plugin detection should crash instead with information about missing plugin.
Related: #14151
Is this issue resolved? See https://github.com/bevyengine/bevy/pull/14160.
bevy = "0.14"
Running `target\debug\bevy_experiment_test.exe`
thread 'main' panicked at C:\Users\BenjaminBrienen\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_state-0.14.2\src\app.rs:70:67:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\bevy_experiment_test.exe` (exit code: 101)
bevy = { path = "../bevy" }
Running `target\debug\bevy_experiment_test.exe`
thread 'main' panicked at C:\Users\BenjaminBrienen\source\bevy\crates\bevy_state\src\app.rs:98:67:
The `StateTransition` schedule is missing. Did you forget to add StatesPlugin or DefaultPlugins before calling init_state?
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\bevy_experiment_test.exe` (exit code: 101)