diff --git a/crates/bevy_openxr/src/openxr/features/overlay.rs b/crates/bevy_openxr/src/openxr/features/overlay.rs index 20e0d7e..6924436 100644 --- a/crates/bevy_openxr/src/openxr/features/overlay.rs +++ b/crates/bevy_openxr/src/openxr/features/overlay.rs @@ -1,6 +1,7 @@ use std::{mem, ptr}; use bevy::prelude::*; +use bevy_xr::session::session_available; use openxr::sys; use crate::{ @@ -15,7 +16,7 @@ impl Plugin for OxrOverlayPlugin { fn build(&self, app: &mut bevy::prelude::App) { app.add_event::(); app.init_resource::(); - app.add_systems(First, add_overlay_info_to_chain); + app.add_systems(First, add_overlay_info_to_chain.run_if(session_available)); } } diff --git a/crates/bevy_xr_utils/src/xr_utils_actions.rs b/crates/bevy_xr_utils/src/xr_utils_actions.rs index d9884e4..2f58ae1 100644 --- a/crates/bevy_xr_utils/src/xr_utils_actions.rs +++ b/crates/bevy_xr_utils/src/xr_utils_actions.rs @@ -60,7 +60,8 @@ use bevy_openxr::{ resources::OxrInstance, session::OxrSession, }; use bevy_xr::session::{session_available, session_running}; -use openxr::{Path, Vector2f}; +use openxr::{ActiveActionSet, Path, Vector2f}; + use std::borrow::Cow; pub struct XRUtilsActionsPlugin; @@ -76,30 +77,30 @@ impl Plugin for XRUtilsActionsPlugin { ); app.add_systems( Startup, - create_openxr_events.in_set(XRUtilsActionSystemSet::CreateEvents), - ); - app.add_systems( - PreUpdate, - sync_active_action_sets.before(OxrActionSetSyncSet), + + create_openxr_events + .in_set(XRUtilsActionSystemSet::CreateEvents) + .run_if(session_available), ); + app.add_systems(Update, sync_active_action_sets.run_if(session_running)); app.add_systems( PreUpdate, sync_and_update_action_states_f32 - .run_if(resource_exists::) + .run_if(session_running) .in_set(XRUtilsActionSystemSet::SyncActionStates) .after(OxrActionSetSyncSet), ); app.add_systems( PreUpdate, sync_and_update_action_states_bool - .run_if(resource_exists::) + .run_if(session_running) .in_set(XRUtilsActionSystemSet::SyncActionStates) .after(OxrActionSetSyncSet), ); app.add_systems( PreUpdate, sync_and_update_action_states_vector - .run_if(resource_exists::) + .run_if(session_running) .in_set(XRUtilsActionSystemSet::SyncActionStates) .after(OxrActionSetSyncSet), );