我希望能够使用Bevy读取和设置窗口设置。我尝试使用基本系统来执行此操作:
fn test_system(mut win_desc: ResMut<WindowDescriptor>) {
win_desc.title = "test".to_string();
println!("{}",win_desc.title);
}
尽管此方法(部分)有效,但它仅为您提供原始设置,并且根本不允许更改。在此示例中,标题将保持不变,但标题的显示将发生变化。在另一个示例中,如果要打印,则不会反映出更改窗口大小(通常在运行时)win_desc.width
。
目前,WindowDescriptor仅在创建窗口期间使用,以后不会更新
为了在调整窗口大小时得到通知,我使用以下系统:
fn resize_notificator(resize_event: Res<Events<WindowResized>>) {
let mut reader = resize_event.get_reader();
for e in reader.iter(&resize_event) {
println!("width = {} height = {}", e.width, e.height);
}
}
其他有用的事件可以在https://github.com/bevyengine/bevy/blob/master/crates/bevy_window/src/event.rs中找到
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句