#Querying TextBundle .with_Style

2 messages · Page 1 of 1 (latest)

orchid void
#

I am trying to dynamically transform a text bundle. How do I query the elements inside the .with_style method as used below? What component do I query? &mut Style isn't yielding anything..
Any help would be appreciated. In the below code, I am printing a console message once the query finds a hit (which hasn't happened), and Ill add the transforms after the query works. So I am really just asking why isn't this query working? Thanks

fn spawn_game_number (mut commands: Commands, asset_server: Res<AssetServer>) {
   
    commands
        .spawn(
        
        // Create a TextBundle that has a Text with a list of sections.
        TextBundle::from_sections([
            TextSection::new(
                "Game Number: ",
                TextStyle {
                    font: asset_server.load("fonts/FreeMono.ttf"),
                    font_size: 20.0,
                    color: Color::GREEN,
                },
            ),
            TextSection::from_style(TextStyle {
                font: asset_server.load("fonts/FreeMono.ttf"),
                font_size: 60.0,
                color: Color::GOLD,
            }),
        ])
    
        .with_style(Style {
        
            position_type: PositionType::Absolute,
            position: UiRect {
                top: Val::Px(10.0),
                right: Val::Px(125.0),
                ..default() 
            },
                ..default()
            },
            )).insert(GameNumber);

}

fn resize_game_number (resize_event: Res<Events<WindowResized>>,
                                     mut query: Query<&mut Style, With <GameNumber>>,
                                )
                                {
  
    let mut event_reader = resize_event.get_reader();
    

    for event in event_reader.iter(&resize_event) {
    
        for mut style in query.iter_mut() {

            console::log_1(&"THE QUERY YIELDED A RESULT".into());        
            
        }
    }
}
storm turret