Skip to content

How to insert resources? #17625

Closed Answered by NiklasEi
cacilhas asked this question in Q&A
Jan 31, 2025 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

I am guessing that the MainMenu state is the initial state? That case I can reproduce. It seems that the first run of the OnEnter schedule happens before Startup/Main. That kind of makes sense to have the correct state already available during the first run of the Main schedule.
I would consider moving the setup into some "Setup" state before MainMenu.

This works for me (instead of in Startup, you could also run the setup in OnEnter of Setup state now):

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .init_state::<MyStates>()
        .add_systems(Startup, setup)
        .add_systems(OnEnter(MyStates::Next), expect)
        .run();
}

fn setup(mut commands: Commands, 

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@cacilhas
Comment options

@NiklasEi
Comment options

NiklasEi Feb 2, 2025
Collaborator

Answer selected by cacilhas
@cacilhas
Comment options

@cacilhas
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants