add prelude
This commit is contained in:
@@ -6,7 +6,7 @@ use bevy_oxr::graphics::XrAppInfo;
|
||||
use bevy_oxr::input::XrInput;
|
||||
use bevy_oxr::resources::{XrFrameState, XrSession};
|
||||
|
||||
use bevy_oxr::xr_init::xr_only;
|
||||
use bevy_oxr::xr_init::{xr_only, EndXrSession, StartXrSession};
|
||||
use bevy_oxr::xr_input::actions::XrActionSets;
|
||||
use bevy_oxr::xr_input::hands::common::HandInputDebugRenderer;
|
||||
use bevy_oxr::xr_input::interactions::{
|
||||
@@ -43,10 +43,22 @@ fn main() {
|
||||
.add_plugins(HandInputDebugRenderer)
|
||||
.add_systems(
|
||||
Update,
|
||||
draw_interaction_gizmos.after(update_interactable_states).run_if(xr_only()),
|
||||
draw_interaction_gizmos
|
||||
.after(update_interactable_states)
|
||||
.run_if(xr_only()),
|
||||
)
|
||||
.add_systems(
|
||||
Update,
|
||||
draw_socket_gizmos
|
||||
.after(update_interactable_states)
|
||||
.run_if(xr_only()),
|
||||
)
|
||||
.add_systems(
|
||||
Update,
|
||||
interactions
|
||||
.before(update_interactable_states)
|
||||
.run_if(xr_only()),
|
||||
)
|
||||
.add_systems(Update, draw_socket_gizmos.after(update_interactable_states).run_if(xr_only()))
|
||||
.add_systems(Update, interactions.before(update_interactable_states).run_if(xr_only()))
|
||||
.add_systems(
|
||||
Update,
|
||||
socket_interactions.before(update_interactable_states),
|
||||
@@ -54,10 +66,24 @@ fn main() {
|
||||
.add_systems(Update, prototype_interaction_input.run_if(xr_only()))
|
||||
.add_systems(Update, update_interactable_states)
|
||||
.add_systems(Update, update_grabbables.after(update_interactable_states))
|
||||
.add_systems(Update, start_stop_session)
|
||||
.add_event::<InteractionEvent>()
|
||||
.run();
|
||||
}
|
||||
|
||||
fn start_stop_session(
|
||||
keyboard: Res<ButtonInput<KeyCode>>,
|
||||
mut start: EventWriter<StartXrSession>,
|
||||
mut stop: EventWriter<EndXrSession>,
|
||||
) {
|
||||
if keyboard.just_pressed(KeyCode::KeyS) {
|
||||
start.send_default();
|
||||
}
|
||||
if keyboard.just_pressed(KeyCode::KeyE) {
|
||||
stop.send_default();
|
||||
}
|
||||
}
|
||||
|
||||
/// set up a simple 3D scene
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
|
||||
@@ -5,6 +5,7 @@ pub mod resource_macros;
|
||||
pub mod resources;
|
||||
pub mod xr_init;
|
||||
pub mod xr_input;
|
||||
pub mod prelude;
|
||||
|
||||
use std::sync::atomic::AtomicBool;
|
||||
|
||||
|
||||
15
src/prelude.rs
Normal file
15
src/prelude.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use bevy::ecs::schedule::{IntoSystemConfigs, SystemConfigs};
|
||||
|
||||
use crate::xr_init::xr_only;
|
||||
pub use crate::xr_input::{QuatConv, Vec2Conv, Vec3Conv};
|
||||
pub use crate::xr_init::schedules::XrSetup;
|
||||
|
||||
pub trait XrSystems<Marker> {
|
||||
fn xr_only(self) -> SystemConfigs;
|
||||
}
|
||||
|
||||
impl<T: IntoSystemConfigs<M>, M> XrSystems<M> for T {
|
||||
fn xr_only(self) -> SystemConfigs {
|
||||
self.into_configs().run_if(xr_only())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user