BSN-spawned Sprite with TextureAtlas from custom-loaded layout renders full texture until a visual field is mutated

Open
#26,398 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start from the reproduction: a bsn! Sprite with texture_atlas whose layout is a HandleTemplate::Path to a custom-loaded TextureAtlasLayout (menu.atlas.ron#layout). Trace how the template resolves that handle and when the sprite's atlas is applied, since only a real field change fixes it. Add a test that spawns the scene and checks the rendered crop without any mutation. Done when the atlas region applies on the first frame and set_changed() is no longer needed.

Written by the indexing model from the issue text.

Description

A-Assets A-Rendering C-Bug S-Needs-Investigation

Description:

When spawning a Sprite via bsn! with a TextureAtlas whose layout is provided through HandleTemplate::Path, the sprite renders the entire texture instead of the atlas sub-region specified by index. The correct cropped region only appears after manually assigning a different value to a visual field (e.g., index, flip_x, color).

Waiting for frames to pass, calling set_changed(), or reassigning a field to its current value has no effect.

Note: A custom AssetLoader for TextureAtlasLayout is implemented and used to load the layout from menu.atlas.ron#layout. The layout asset itself loads successfully — after the manual visual mutation, the correct region is displayed.

Reproduction:

fn menu() -> impl Scene {
    bsn! {
        Sprite {
            image: "menu.atlas.ron#texture",
            texture_atlas: {
                TextureAtlasTemplate {
                    layout: HandleTemplate::Path("menu.atlas.ron#layout".into()),
                    index: 0,
                }
            }
        }
    }
}

Expected: The sprite renders only the region defined by the TextureAtlasLayout at index 0.

Actual:

  • The sprite renders the full texture, as if texture_atlas were None.
  • sprite.set_changed() and assigning the same value do not fix it.
  • Only a real visual change (different index, flipped boolean, changed color) triggers correct atlas cropping.
Dominant language
Rust
Stars
49.8k
Forks
5.1k
Avg merge
3d 4h
Merged PRs (30d)
136

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bevyengine/bevy

All issues in bevyengine/bevy

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.