You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using custom schematics to add player sprite and some text to the window.
Not sure exactly what is the root problem, but after a few changes including migrating from bevy_proto 0.11 release to latest github version, I couldn't get the add child text working. The screenshot demonstrating the child text appearance in old build vs new.
Old build:
New build:
impl Schematic for PlayerSpriteSheet {
// Applying `EnemyInput` type
type Input = PlayerSpriteSheet;
fn apply(input: &Self::Input, _id: SchematicId, context: &mut SchematicContext) {
//skipped some section to load atlas & transform
context.entity_mut().unwrap().insert((
SpriteSheetBundle {
texture_atlas: texture_atlas_handle,
sprite: TextureAtlasSprite::new(input.sprite.animation.first),
transform,
..default()
},
input.sprite.animation,
AnimationTimer(Timer::from_seconds(
input.sprite.animation.duration,
TimerMode::Repeating,
)),
PlayerSprite,
));
// Insert the Defend Text within the 2d world (i.e. not using node UI)
let text = "Defend: 1".to_string();
let defend_text = context
.world_mut()
.spawn((
Text2dBundle {
text: Text::from_section(
// Accepts a String or any type that converts into a String, such as &str.
text,
TextStyle {
font_size: 200.0,
color: Color::RED,
..default()
},
),
visibility: Visibility::Visible,
..Default::default()
},
PlayerDefendUIText,
))
.id();
// add health bar & text child entity to Enemy
context.entity_mut().unwrap().add_child(defend_text);
}
// skipped
// fn remove()
// fn preload_dependencies()
I have a debug system/function to print all entity to console, and when I do that, the child entity exist. Not sure what else can be done to diagnose this new behavior further.
I am using custom schematics to add player sprite and some text to the window.
Not sure exactly what is the root problem, but after a few changes including migrating from bevy_proto 0.11 release to latest github version, I couldn't get the add child text working. The screenshot demonstrating the child text appearance in old build vs new.
Old build:

New build:

I have a debug system/function to print all entity to console, and when I do that, the child entity exist. Not sure what else can be done to diagnose this new behavior further.
The text was updated successfully, but these errors were encountered: