@@ -35,6 +35,13 @@ pub struct WorkbenchConfig {
3535 pub layout : layout:: LayoutMode ,
3636 pub show_menu_bar : bool ,
3737 pub show_console : bool ,
38+ /// Whether to show the built-in Play/Stop/Pause toolbar.
39+ /// Set to `false` for tools that don't use the game mode system
40+ /// (e.g., animation editors that are always "running").
41+ pub show_toolbar : bool ,
42+ /// Whether to enable the built-in GameView render-to-texture pipeline.
43+ /// Set to `false` if your app has its own preview/rendering setup.
44+ pub enable_game_view : bool ,
3845}
3946
4047impl Default for WorkbenchConfig {
@@ -43,6 +50,8 @@ impl Default for WorkbenchConfig {
4350 layout : layout:: LayoutMode :: Auto ,
4451 show_menu_bar : true ,
4552 show_console : true ,
53+ show_toolbar : true ,
54+ enable_game_view : true ,
4655 }
4756 }
4857}
@@ -94,39 +103,63 @@ impl Plugin for WorkbenchPlugin {
94103 } )
95104 . insert_resource ( i18n:: I18n :: new ( settings. locale ) )
96105 . insert_resource ( font:: FontState :: default ( ) )
106+ . add_message :: < menu_bar:: MenuAction > ( )
97107 . add_systems ( Update , layout:: detect_layout_system)
98- . add_systems ( Update , mode:: mode_input_system)
99- . add_systems ( Update , mode:: run_game_schedule_system)
100- . add_systems ( OnEnter ( mode:: EditorMode :: Play ) , mode:: on_enter_play)
101- . add_systems (
102- OnEnter ( mode:: EditorMode :: Play ) ,
103- console:: console_auto_clear_system,
104- )
105- . add_systems ( OnEnter ( mode:: EditorMode :: Pause ) , mode:: on_enter_pause)
106- . add_systems ( OnEnter ( mode:: EditorMode :: Edit ) , mode:: on_enter_edit)
107108 . add_systems ( Update , undo:: undo_input_system)
108109 . add_systems ( PreUpdate , assign_primary_egui_context_system)
109110 . add_systems ( PreUpdate , console:: console_drain_system)
110- . add_systems ( PreUpdate , inspector:: mark_internal_entities_system)
111- // UI systems must run in EguiPrimaryContextPass (bevy_egui 0.39 multi-pass mode)
112- . add_systems (
113- EguiPrimaryContextPass ,
111+ . add_systems ( PreUpdate , inspector:: mark_internal_entities_system) ;
112+
113+ // Mode system (Play/Stop/Pause) — only when toolbar is enabled
114+ if self . config . show_toolbar {
115+ app. add_systems ( Update , mode:: mode_input_system)
116+ . add_systems ( Update , mode:: run_game_schedule_system)
117+ . add_systems ( OnEnter ( mode:: EditorMode :: Play ) , mode:: on_enter_play)
118+ . add_systems (
119+ OnEnter ( mode:: EditorMode :: Play ) ,
120+ console:: console_auto_clear_system,
121+ )
122+ . add_systems ( OnEnter ( mode:: EditorMode :: Pause ) , mode:: on_enter_pause)
123+ . add_systems ( OnEnter ( mode:: EditorMode :: Edit ) , mode:: on_enter_edit) ;
124+ }
125+
126+ // UI systems must run in EguiPrimaryContextPass (bevy_egui 0.39 multi-pass mode)
127+ {
128+ let ui_systems = (
114129 (
115- (
116- config:: config_apply_system,
117- font:: install_fonts_system,
118- theme:: apply_theme_system,
119- )
120- . chain ( ) ,
121- game_view:: game_view_sync_system,
122- menu_bar:: menu_bar_system,
123- dock:: tiles_ui_system,
130+ config:: config_apply_system,
131+ font:: install_fonts_system,
132+ theme:: apply_theme_system,
124133 )
125134 . chain ( ) ,
126- ) ;
135+ game_view:: game_view_sync_system
136+ . run_if ( resource_exists :: < game_view:: GameViewState > ) ,
137+ menu_bar:: menu_bar_system,
138+ )
139+ . chain ( ) ;
140+
141+ if self . config . show_toolbar {
142+ app. add_systems (
143+ EguiPrimaryContextPass ,
144+ ( ui_systems, menu_bar:: toolbar_system, dock:: tiles_ui_system) . chain ( ) ,
145+ ) ;
146+ } else {
147+ app. add_systems (
148+ EguiPrimaryContextPass ,
149+ ( ui_systems, dock:: tiles_ui_system) . chain ( ) ,
150+ ) ;
151+ }
152+ }
153+
154+ // Game view render-to-texture pipeline
155+ if self . config . enable_game_view {
156+ app. add_plugins ( game_view:: GameViewPlugin ) ;
157+ }
127158
128159 // Register built-in panels
129- app. register_panel ( game_view:: GameViewPanel :: default ( ) ) ;
160+ if self . config . enable_game_view {
161+ app. register_panel ( game_view:: GameViewPanel :: default ( ) ) ;
162+ }
130163 app. register_panel ( inspector:: InspectorPanel ) ;
131164 if self . config . show_console {
132165 app. register_panel ( console:: ConsolePanel ) ;
0 commit comments