Screenshot

Screenshot

  1. bevy_render::camera::camera::RenderTarget

Description

A component that signals to the renderer to capture a screenshot this frame.

This component should be spawned on a new entity with an observer that will trigger with [ScreenshotCaptured] when the screenshot is ready.

Screenshots are captured asynchronously and may not be available immediately after the frame that the component is spawned on. The observer should be used to handle the screenshot when it is ready.

Note that the screenshot entity will be despawned after the screenshot is captured and the observer is triggered.

Usage

# use bevy_ecs::prelude::*;
# use bevy_render::view::screenshot::{save_to_disk, Screenshot};

fn take_screenshot(mut commands: Commands) {
   commands.spawn(Screenshot::primary_window())
      .observe(save_to_disk("screenshot.png"));
}

Functions