This crate makes it easy to use the undo-operation on bevy.
```rust
use bevy::prelude::; use bevy_undo2::prelude::;
struct GreetEvent(String);
fn main() {
App::new()
.addplugins(DefaultPlugins)
.addplugins(UndoPlugin)
.addsystems(Startup, setup)
.addsystems(Update, (keyboardinputsystem, readundoeventsystem))
.addundo_event::
fn setup(
mut commands: Commands,
mut scheduler: UndoScheduler
fn keyboardinputsystem( mut requester: UndoRequester, key: Res>, ) { if key.pressed(KeyCode::R) { requester.undo(); } }
fn readundoeventsystem(
mut er: EventReader
```rust use bevy::prelude::; use bevy_undo2::prelude::;
fn main() { App::new() .addplugins(DefaultPlugins) .addplugins(UndoPlugin) .addsystems(Startup, setup) .addsystems(Update, keyboardinputsystem) .run(); }
fn setup(
mut commands: Commands,
mut scheduler: UndoCallbackScheduler,
asset: Res
scheduler.register(move |cmd| {
cmd.entity(text).despawn();
});
}
fn keyboardinputsystem( mut requester: UndoRequester, key: Res>, ) { if key.pressed(KeyCode::R) { requester.undo(); } } ```
| this crate | bevy | |------------|--------| | 0.0.1 | 0.11.0 |