Rust 在Bevy游戏引擎中将1000x1000像素的纹理分配给SpriteSheetBundle大约需要5秒钟

Rust 在Bevy游戏引擎中将1000x1000像素的纹理分配给SpriteSheetBundle大约需要5秒钟,rust,game-development,bevy,Rust,Game Development,Bevy,有没有办法改善这种情况,还是我只是用错了引擎? 我试图通过首先创建和生成质量较低的背景图像来解决这个问题 fn spawn_background(commands: &mut Commands, texture: Res<Textures>) { commands .spawn(SpriteSheetBundle { texture_atlas: texture.background_low_texture.clone(),

有没有办法改善这种情况,还是我只是用错了引擎? 我试图通过首先创建和生成质量较低的背景图像来解决这个问题

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 spawn_背景(命令:&mut命令,纹理:Res){
命令
.spawn(SpriteSheetBundle{
纹理\u图集:纹理。背景\u低\u纹理。克隆(),
transform:transform::from_scale(Vec3::splat(10.0)),
…默认值::默认值()
})
.带(假人)
.有(背景);
命令
.spawn(SpriteSheetBundle{
纹理图集:纹理。背景纹理。克隆(),
transform:transform::from_scale(Vec3::splat(10.0)),
…默认值::默认值()
})
.带(假人)
.有(背景);
命令
.spawn(SpriteSheetBundle{
纹理\图集:纹理。背景\纹理。克隆(),
transform:transform::from_scale(Vec3::splat(10.0)),
…默认值::默认值()
})
.有(背景);
}
我正在像这样将纹理加载到“纹理”资源

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),
    });
}
fn设置(
命令:&mut命令,
资源服务器:Res,
mut纹理地图集:ResMut,
) {
让background_texture_handle=asset_server.load(“textures/background.png”);
让background\u texture\u atlas=TextureAtlas::from\u grid(background\u texture\u handle,Vec2::new(1000.0,1000.0),1,1);
让background\u low\u texture\u handle=asset\u server.load(“textures/background\u low.png”);
让background_low_texture_atlas=TextureAtlas::from_grid(background_low_texture_handle,Vec2::new(1000.0,1000.0),1,1);
让background\u med\u texture\u handle=asset\u server.load(“textures/background\u med.png”);
让background\u med\u texture\u atlas=TextureAtlas::from\u grid(background\u med\u texture\u handle,Vec2::new(1000.0,1000.0),1,1);
命令。插入资源(纹理){
背景纹理:纹理地图集。添加(背景纹理地图集),
背景低纹理:纹理地图集。添加(背景低纹理地图集),
背景纹理:纹理地图集。添加(背景纹理地图集),
});
}

使用
--release
命令行选项进行编译时,由于版本配置文件启用了优化功能,因此运行速度要快得多


使用
--release
命令行选项进行编译时,由于版本配置文件启用了优化功能,因此运行速度要快得多


您在--release模式下尝试过这个吗?哇,谢谢您,在--release模式下,它工作得非常好!您在
--release
模式下尝试过这个吗?哇,谢谢您,在--release模式下,它工作得非常好!