Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sprite spawned after start is not displayed #996

Closed
mockersf opened this issue Dec 3, 2020 · 2 comments · Fixed by #1000
Closed

sprite spawned after start is not displayed #996

mockersf opened this issue Dec 3, 2020 · 2 comments · Fixed by #1000
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior

Comments

@mockersf
Copy link
Member

mockersf commented Dec 3, 2020

Bevy version

git 7699f8b6db0af6ca62fcd033e05df4f6c71ecb23 (current master at the time of this issue) - #987

Operating system & version

macOS 10.15.7

What you did

Spawn a sprite during game when none has been displayed at start

use bevy::prelude::*;

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup)
        .add_system(display)
        .run();
}

fn setup(commands: &mut Commands) {
    commands.spawn(Camera2dBundle::default());
}

fn display(
    commands: &mut Commands,
    mut first: Local<bool>,
    asset_server: Res<AssetServer>,
    mut materials: ResMut<Assets<ColorMaterial>>,
) {
    if !*first {
        let texture_handle = asset_server.load("branding/icon.png");
        info!(
            "displaying sprite: {:?}",
            commands
                .spawn(SpriteBundle {
                    material: materials.add(texture_handle.into()),
                    ..Default::default()
                })
                .current_entity()
        );
        *first = true;
    }
}

What you expected to happen

The sprite should have been displayed

What actually happened

The sprite wasn't displayed

Additional information

It was working with previous bevy commit

@cart
Copy link
Member

cart commented Dec 3, 2020

Nice catch. I'll try to fix this asap!

@cart cart added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen labels Dec 3, 2020
@cart
Copy link
Member

cart commented Dec 3, 2020

  1. It doesn't display because the material asset's RenderResouceBindings aren't populated for the Texture/Sampler. The base color is populated
  2. Rendering sprites with solid color materials (not textures) works

So for some reason texture bindings aren't getting populated for texture assets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants