custom_schedule/
custom_schedule.rs1use bevy::{
5 app::MainScheduleOrder,
6 ecs::schedule::{ExecutorKind, ScheduleLabel},
7 prelude::*,
8};
9
10#[derive(ScheduleLabel, Debug, Hash, PartialEq, Eq, Clone)]
11struct SingleThreadedUpdate;
12
13#[derive(ScheduleLabel, Debug, Hash, PartialEq, Eq, Clone)]
14struct CustomStartup;
15
16fn main() {
17 let mut app = App::new();
18
19 let mut custom_update_schedule = Schedule::new(SingleThreadedUpdate);
23 custom_update_schedule.set_executor_kind(ExecutorKind::SingleThreaded);
24
25 app.add_schedule(custom_update_schedule);
28
29 let mut main_schedule_order = app.world_mut().resource_mut::<MainScheduleOrder>();
39 main_schedule_order.insert_after(Update, SingleThreadedUpdate);
40
41 app.add_schedule(Schedule::new(CustomStartup));
44
45 let mut main_schedule_order = app.world_mut().resource_mut::<MainScheduleOrder>();
46 main_schedule_order.insert_startup_after(PreStartup, CustomStartup);
47
48 app.add_systems(SingleThreadedUpdate, single_threaded_update_system)
49 .add_systems(CustomStartup, custom_startup_system)
50 .add_systems(PreStartup, pre_startup_system)
51 .add_systems(Startup, startup_system)
52 .add_systems(First, first_system)
53 .add_systems(Update, update_system)
54 .add_systems(Last, last_system)
55 .run();
56}
57
58fn pre_startup_system() {
59 println!("Pre Startup");
60}
61
62fn startup_system() {
63 println!("Startup");
64}
65
66fn custom_startup_system() {
67 println!("Custom Startup");
68}
69
70fn first_system() {
71 println!("First");
72}
73
74fn update_system() {
75 println!("Update");
76}
77
78fn single_threaded_update_system() {
79 println!("Single Threaded Update");
80}
81
82fn last_system() {
83 println!("Last");
84}