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 was upgrading my RPG textboxes to use the new 9-slicing feature, but creating a sliced sprite with an anchor not set to Anchor::Center does not work right.
What went wrong
Creating the textbox background with Anchor::Center works fine, and looks like this:
Created with this code:
let sprite_child = commands
.spawn(SpriteBundle{sprite:Sprite{custom_size:Some(vec2(296.5,83.5)),
..default()},transform:Transform{translation:Vec3::new(0.0, -77.75,4.9),rotation:Quat::IDENTITY,scale:Vec3::splat(1.0),},texture: asset_server.load("textbox.png"),
..default()}).insert(ImageScaleMode::Sliced(TextureSlicer{border:BorderRect::square(13.0),max_corner_scale:1.0,
..default()})).id();
Creating the textbox background with Anchor::TopLeft (with position adjusted correspondingly) does not work fine, and looks like this:
Created with this code:
let sprite_child = commands
.spawn(SpriteBundle{sprite:Sprite{anchor:Anchor::TopLeft,custom_size:Some(vec2(296.5,83.5)),
..default()},transform:Transform{translation:Vec3::new(-148.25, -36.0,4.9),rotation:Quat::IDENTITY,scale:Vec3::splat(1.0),},texture: asset_server.load("textbox.png"),
..default()}).insert(ImageScaleMode::Sliced(TextureSlicer{border:BorderRect::square(13.0),max_corner_scale:1.0,
..default()})).id();
Additional information
My guess is that the anchor is being taken into consideration when scaling the center of the sliced texture, but not for the other parts.
The text was updated successfully, but these errors were encountered:
…2769)
# Objective
Fixes#12408 .
Fixes#12680.
## Solution
- Recaclulated anchor from dimensions of sprite to dimension of each
part of it (each part contains its own anchor)
Bevy version
v0.13.1
What you did
I was upgrading my RPG textboxes to use the new 9-slicing feature, but creating a sliced sprite with an anchor not set to
Anchor::Center
does not work right.What went wrong
Creating the textbox background with
Anchor::Center
works fine, and looks like this:Created with this code:
Creating the textbox background with
Anchor::TopLeft
(with position adjusted correspondingly) does not work fine, and looks like this:Created with this code:
Additional information
My guess is that the anchor is being taken into consideration when scaling the center of the sliced texture, but not for the other parts.
The text was updated successfully, but these errors were encountered: