Skip to content
Snippets Groups Projects
web.rs 905 B
#[cfg(target_arch = "wasm32")]
mod __plugin {
	use bevy::app::{App, Plugin, CoreStage};
	pub fn handle_startup_fullscreen() {
		if micro_bevy_web_utils::bindings::is_touch_device() {
			micro_bevy_web_utils::bindings::make_selector_fullscreen("canvas".to_string());
			micro_bevy_web_utils::bindings::bind_selector_touch_events("canvas".to_string());
			micro_bevy_web_utils::bindings::orientation_lock("landscape".to_string());
		}
	}

	pub struct WebPlugin;
	impl Plugin for WebPlugin {
		fn build(&self, app: &mut App) {
				app.add_startup_system(handle_startup_fullscreen)
					.add_system_to_stage(
						CoreStage::First,
						micro_bevy_web_utils::bevy::emit_touch_events,
					);
			}
	}
}

#[cfg(not(target_arch = "wasm32"))]
mod __plugin {
	use bevy::app::{App, Plugin};
	pub struct WebPlugin;
	impl Plugin for WebPlugin {
		fn build(&self, app: &mut App) {}
	}
}

pub use __plugin::WebPlugin;