rust - 如何使用 Bevy 在创建后获取和设置 Window 信息?
问题描述
我希望能够使用 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找到
推荐阅读
- tomcat - 如何运行从厨师超市下载的tomcat食谱?
- javascript - 将 Express 函数集成到 Typescript
- visual-studio - Visual Studio 2015 选择统一实例窗口为空
- scala - Scala 中的 a += b 何时变为 a = a + b?
- python - 停止运行部分代码的最有效方法
- django - 防止 Django 中的媒体文件夹被新更新覆盖
- html - Firebase 未注销用户
- android - 统一类型不匹配错误 - OpenGL ES 3.0 着色器程序在 Android 7/8/9 上链接但在 iOS 10/11 上失败?
- mysql - mysql查询用于在存储过程中执行的长查询
- jquery - dataTables columnDefs 重新加载时更改