Headless -> GUI Application based on condtions #22291
Replies: 2 comments 15 replies
-
|
Personally, I think you shouldn't "spawn" things like that within the lifecycle of an Activity/UIViewController. For example, on the Android operating system, the Window (Screen) is only created during the ONCREATE phase and rendered (visible) during the ONSTART phase. Each Activity can contain fragments, etc., and you can "spawn" those fragments, widgets, UI controls, etc. Furthermore, in a game application, what are the advantages and disadvantages of spawning multiple "windows"? |
Beta Was this translation helpful? Give feedback.
-
|
There shouldn't be a problem spawning a window conditionally, after your application started. As you're adding plugins manually instead of through If you try this it works for me: use bevy::{diagnostic::FrameCount, prelude::*};
fn main() {
App::new()
.add_plugins((DefaultPlugins.set(WindowPlugin {
primary_window: None,
exit_condition: bevy::window::ExitCondition::DontExit,
..default()
}),))
.add_systems(Update, spawn_window)
.run();
}
fn spawn_window(mut commands: Commands, frame_count: Res<FrameCount>) {
if frame_count.0 == 100 {
commands.spawn(Window {
title: "Late window".to_owned(),
..default()
});
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to conditionally create a window later in the application's lifecycle, but because there is no Window on startup WinitPlugin does not setup the schedule runner. It also interferes with ScheduleRunnerPlugin, and when it non-deterministically gives it control, it does not spawn the window. What would be the correct way to do what I'm trying to do?
Beta Was this translation helpful? Give feedback.
All reactions