Run handle_lifetime only when AudioSink is added to the world (#17637)

# Objective

Fixes:
https://discord.com/channels/691052431525675048/756998293665349712/1335019849516056586

## Solution

Let's wait till `AudioSInk` will be added to the world.

## Testing

Run ios example
This commit is contained in:
Predko Silvestr 2025-02-02 02:07:02 +02:00 committed by François Mockers
parent 4aca402a75
commit 9d122a7d12

View File

@ -37,7 +37,16 @@ fn main() {
// This can help reduce cpu usage on mobile devices
.insert_resource(WinitSettings::mobile())
.add_systems(Startup, (setup_scene, setup_music))
.add_systems(Update, (touch_camera, button_handler, handle_lifetime))
.add_systems(
Update,
(
touch_camera,
button_handler,
// Only run the lifetime handler when an [`AudioSink`] component exists in the world.
// This ensures we don't try to manage audio that hasn't been initialized yet.
handle_lifetime.run_if(any_with_component::<AudioSink>),
),
)
.run();
}