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

Fix component hook registration #17

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

Azorlogh
Copy link
Contributor

Since bevy 0.14.1, StateTransition now runs before PreStartup

As a result, this example fails on bevy 0.14.1:

use bevy::prelude::*;
use bevy_quill::{Element, QuillPlugin, View};

#[derive(States, Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct Foo(pub bool);

fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins.set(ImagePlugin::default_nearest()),
            QuillPlugin,
        ))
        .init_state::<Foo>()
        .add_systems(OnEnter(Foo(false)), on_enter)
        .run();
}

fn on_enter(mut commands: Commands) {
    commands.spawn((Element::<NodeBundle>::new().children("hello!").to_root(),));
}

With the following error:

Components hooks cannot be modified if the component already exists in an archetype, use init_component if bevy_quill_core::view::ViewRoot may already be in use
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_quill_core::view::cleanup_view_roots`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!

This moves the registration earlier to ensure it runs before any ViewRoot is created

@viridia viridia merged commit 6a18fab into viridia:main Aug 12, 2024
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

Successfully merging this pull request may close these issues.

2 participants