Normalization anchor for sprite slice in dimensions of this slice (#12769)
# 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)
This commit is contained in:
parent
6b0e3fa572
commit
a5fa32e1e7
@ -53,10 +53,21 @@ impl ComputedTextureSlices {
|
|||||||
flip_x,
|
flip_x,
|
||||||
flip_y,
|
flip_y,
|
||||||
image_handle_id: handle.id(),
|
image_handle_id: handle.id(),
|
||||||
anchor: sprite.anchor.as_vec(),
|
anchor: Self::redepend_anchor_from_sprite_to_slice(sprite, slice),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn redepend_anchor_from_sprite_to_slice(sprite: &Sprite, slice: &TextureSlice) -> Vec2 {
|
||||||
|
let sprite_size = sprite
|
||||||
|
.custom_size
|
||||||
|
.unwrap_or(sprite.rect.unwrap_or_default().size());
|
||||||
|
if sprite_size == Vec2::ZERO {
|
||||||
|
sprite.anchor.as_vec()
|
||||||
|
} else {
|
||||||
|
sprite.anchor.as_vec() * sprite_size / slice.draw_size
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates sprite slices for a `sprite` given a `scale_mode`. The slices
|
/// Generates sprite slices for a `sprite` given a `scale_mode`. The slices
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user