mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 14:08:32 +00:00
If you need to build a texture atlas from an already created texture that is not match a grid, you need to use new_empty and add_texture to create it. However it is not straight forward to get the index to be used with TextureAtlasSprite. add_texture should be changed to return the index to the texture. Currently you can do something like this: ```rs let texture = asset_server.load::<Texture>::("texture.png"); let texture_atlas = TextureAtlas::new_empty(texture, Vec2::new(40.0, 40.0)); texture_atlas.add_texture(Rect { min: Vec2::new(20.0, 20.0), max: Vec2::new(40.0, 40.0), }); let index = (texture_atlas.len() - 1) as u32; let texture_atlas_sprite = TextureAtlasSprite { index, Default::default() }; ``` But this is more clear ```rs let index = texture_atlas.add_texture(Rect { min: Vec2::new(20.0, 20.0), max: Vec2::new(40.0, 40.0), }); ``` |
||
---|---|---|
.. | ||
bevy_app | ||
bevy_asset | ||
bevy_audio | ||
bevy_core | ||
bevy_derive | ||
bevy_diagnostic | ||
bevy_dylib | ||
bevy_dynamic_plugin | ||
bevy_ecs | ||
bevy_gilrs | ||
bevy_gltf | ||
bevy_input | ||
bevy_internal | ||
bevy_log | ||
bevy_macro_utils | ||
bevy_math | ||
bevy_pbr | ||
bevy_reflect | ||
bevy_render | ||
bevy_scene | ||
bevy_sprite | ||
bevy_tasks | ||
bevy_text | ||
bevy_transform | ||
bevy_ui | ||
bevy_utils | ||
bevy_wgpu | ||
bevy_window | ||
bevy_winit |