Crates.io | bevy_capture_media |
lib.rs | bevy_capture_media |
version | 0.0.2 |
source | src |
created_at | 2022-08-12 22:11:16.347071 |
updated_at | 2022-08-12 22:31:51.814001 |
description | Event based screenshots & recording for Bevy Engine |
homepage | |
repository | https://github.com/Commander-lol/bevy_capture_media |
max_upload_size | |
id | 644289 |
size | 55,353 |
Event based image & video capture for Bevy
Duration
)wasm
supportuse std::time::Duration;
use bevy::prelude::*;
use bevy_capture_media::{MediaCapture, BevyCapturePlugin};
pub fn spawn_cameras(
mut commands: Commands,
mut capture: MediaCapture,
) {
let camera_entity = commands
.spawn_bundle(Camera2dBundle::default())
.id();
// The tracking ID (1357) is arbitrary, but uniquely identifies this tracker
capture.start_tracking_camera(1357, camera_entity, Duration::from_secs(5));
}
pub fn take_screenshot(
input: Res<Input<KeyCode>>,
mut capture: MediaCapture,
) {
if input.just_released(KeyCode::RShift) {
// If you have many cameras, consider storing their IDs
// in a resource
capture.capture_png(1357);
}
}
fn main() {
app::new()
.add_plugin(DefaultPlugins)
.add_plugins(bevy_capture_media::BevyCapturePlugin)
.add_startup_system(spawn_cameras)
.add_system(take_screenshot);
}
https://user-images.githubusercontent.com/2522620/184448446-8cd5214b-81fa-41a3-bdbe-156412cc99cc.mp4
All suggestions, issues, and pull requests are welcome. Any contributions must be licensed compatibly with this repository.
Yes! This is great! There is a small checklist that any new format will need to meet to be included: