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 GitHub
parent e57f73207e
commit 082d87141f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -41,7 +41,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();
}