Describe the bug
Spawning a new entity with ParticleEffect component in PostUpdate schedule results in unwrap:
thread 'Compute Task Pool (1)' panicked at /<...>/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_hanabi-0.12.2/src/render/mod.rs:2107:59:
called `Option::unwrap()` on a `None` value
Expected behavior
I would expect any schedule to be valid for spawning particle effects.
To Reproduce
Here is a diff for examples/spawn_on_command to reproduce this crash:
Crate versions
bevy
version: 0.14.1bevy_hanabi
version: 0.12.2Describe the bug Spawning a new entity with
ParticleEffect
component inPostUpdate
schedule results in unwrap:Expected behavior I would expect any schedule to be valid for spawning particle effects.
To Reproduce Here is a diff for
examples/spawn_on_command
to reproduce this crash:Diff
```diff diff --git a/examples/spawn_on_command.rs b/examples/spawn_on_command.rs index 7b4c0b5..42f324b 100644 --- a/examples/spawn_on_command.rs +++ b/examples/spawn_on_command.rs @@ -56,12 +56,15 @@ fn main() -> Result<(), Box> {
app.add_plugins(WorldInspectorPlugin::default());
app.add_systems(Startup, setup)
- .add_systems(Update, (utils::close_on_esc, update))
+ .add_systems(PostUpdate, (utils::close_on_esc, update))
.run();
Ok(())
}
+#[derive(Resource)]
+struct Storage(Handle);
+
#[derive(Component)]
struct Ball {
velocity: Vec2,
@@ -119,7 +122,7 @@ fn setup(
.insert(Name::new("ball"));
// Set `spawn_immediately` to false to spawn on command with Spawner::reset()
- let spawner = Spawner::once(100.0.into(), false);
+ let spawner = Spawner::once(100.0.into(), true);
let writer = ExprWriter::new();
@@ -186,24 +189,17 @@ fn setup(
.render(ScreenSpaceSizeModifier),
);
- commands
- .spawn(ParticleEffectBundle::new(effect))
- .insert(Name::new("effect"));
+ commands.insert_resource(Storage(effect));
}
fn update(
+ mut commands: Commands,
+ storage: Res,
mut balls: Query<(&mut Ball, &mut Transform)>,
- mut effect: Query<(&mut EffectProperties, &mut EffectSpawner, &mut Transform), Without>,
time: Res