bevy icon indicating copy to clipboard operation
bevy copied to clipboard

State API should panic when missing `StatePlugin`

Open MiniaczQ opened this issue 1 year ago • 1 comments

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.

MiniaczQ avatar Jul 09 '24 13:07 MiniaczQ

Related: #14151

rparrett avatar Jul 09 '24 14:07 rparrett

Is this issue resolved? See https://github.com/bevyengine/bevy/pull/14160.

benfrankel avatar Oct 26 '24 21:10 benfrankel

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)

BenjaminBrienen avatar Oct 26 '24 22:10 BenjaminBrienen