Created
July 14, 2025 10:04
-
-
Save ejrh/4f851c84c233815f13befded2a4fcc27 to your computer and use it in GitHub Desktop.
text culling bug, bevy 16.1, windows 11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::default::Default; | |
use bevy::color::palettes::basic::{BLACK, WHITE}; | |
use bevy::prelude::*; | |
use bevy::sprite::Anchor; | |
use bevy::text::TextBounds; | |
fn main() { | |
App::new() | |
.add_plugins(DefaultPlugins) | |
.add_systems(Startup, setup) | |
.run(); | |
} | |
fn setup( | |
mut commands: Commands, | |
asset_server: Res<AssetServer>) | |
{ | |
let font = asset_server.load("fonts/FiraMono-Medium.ttf"); | |
let camera = Camera2d::default(); | |
commands.spawn(( | |
camera, | |
)); | |
const CHAT_WIDTH: f32 = 400.0; | |
const CHAT_HEIGHT: f32 = 400.0; | |
const CHAT_TOP: f32 = 300.0; | |
const CHAT_LEFT: f32 = 400.0; | |
commands.spawn(( | |
Sprite::from_color(BLACK, Vec2::new(CHAT_WIDTH, CHAT_HEIGHT)), | |
Transform::from_xyz(CHAT_LEFT + CHAT_WIDTH/2.0, CHAT_TOP - CHAT_HEIGHT/2.0, 0.0), | |
)).with_child(( | |
Text2d::new("some words here"), | |
//Text2d::new("some words here\nand\nsome more"), // <-- this line instead, then it works | |
TextFont::from_font(font.clone()).with_font_size(30.0), | |
TextColor::from(WHITE), | |
Anchor::TopLeft, | |
TextBounds::new(CHAT_WIDTH, CHAT_HEIGHT), // <-- comment this out, then it works | |
Transform::from_xyz(-CHAT_WIDTH/2.0, CHAT_HEIGHT/2.0, 1.0), | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment