rust - 在 Bevy 游戏引擎中将 1000x1000 像素纹理分配给 SpriteSheetBundle 大约需要 5 秒
问题描述
有没有办法改善这种情况,还是我只是使用错误的引擎?我试图通过首先创建和生成质量较低的背景图像来解决这个问题。
fn spawn_background(commands: &mut Commands, texture: Res<Textures>) {
commands
.spawn(SpriteSheetBundle {
texture_atlas: texture.background_low_texture.clone(),
transform: Transform::from_scale(Vec3::splat(10.0)),
..Default::default()
})
.with(Dummy)
.with(Background);
commands
.spawn(SpriteSheetBundle {
texture_atlas: texture.background_med_texture.clone(),
transform: Transform::from_scale(Vec3::splat(10.0)),
..Default::default()
})
.with(Dummy)
.with(Background);
commands
.spawn(SpriteSheetBundle {
texture_atlas: texture.background_texture.clone(),
transform: Transform::from_scale(Vec3::splat(10.0)),
..Default::default()
})
.with(Background);
}
我正在像这样将纹理加载到“纹理”资源中
fn setup(
commands: &mut Commands,
asset_server: Res<AssetServer>,
mut texture_atlases: ResMut<Assets<TextureAtlas>>,
) {
let background_texture_handle = asset_server.load("textures/background.png");
let background_texture_atlas = TextureAtlas::from_grid(background_texture_handle, Vec2::new(1000.0, 1000.0), 1, 1);
let background_low_texture_handle = asset_server.load("textures/background_low.png");
let background_low_texture_atlas = TextureAtlas::from_grid(background_low_texture_handle, Vec2::new(1000.0, 1000.0), 1, 1);
let background_med_texture_handle = asset_server.load("textures/background_med.png");
let background_med_texture_atlas = TextureAtlas::from_grid(background_med_texture_handle, Vec2::new(1000.0, 1000.0), 1, 1);
commands.insert_resource(Textures {
background_texture: texture_atlases.add(background_texture_atlas),
background_low_texture: texture_atlases.add(background_low_texture_atlas),
background_med_texture: texture_atlases.add(background_med_texture_atlas),
});
}
解决方案
使用--release
命令行选项编译时,它运行得更快,因为发布配置文件启用了优化。
推荐阅读
- php - 无法使用 php 取消条带计费订阅
- google-maps - 如何在 Google Maps API 中将街景缩略图添加到标记工具提示
- pandas - 创建由 Groupby 和转换产生的数据框列
- c++ - 从当前时间减去 40 分钟
- asp.net - 在 ASP.NET 和 IIS 中部署时覆盖 Web 配置文件
- python - 如何在 mutate dplython 中使用正则表达式来添加新列
- sequelize.js - 如何在 sequelize 中使用 COUNT、GROUP BY、ORDER BY 编写查询
- gcc - SIGILL 堆栈溢出
- jquery - 单击按钮后清除输入值 ($('#id').val(''); ) 不起作用
- xamarin.forms - 在 iOS 上抛出“No embeddedresource found for NameSpace.App”,但在 Android 上没有