Re-add missing call and use non-panicking method
This commit is contained in:
parent
7b98031c49
commit
ee34f4660d
@ -46,13 +46,17 @@ impl BuildChildrenTransformExt for EntityWorldMut<'_> {
|
|||||||
fn set_parent_in_place(&mut self, parent: Entity) -> &mut Self {
|
fn set_parent_in_place(&mut self, parent: Entity) -> &mut Self {
|
||||||
// FIXME: Replace this closure with a `try` block. See: https://github.com/rust-lang/rust/issues/31436.
|
// FIXME: Replace this closure with a `try` block. See: https://github.com/rust-lang/rust/issues/31436.
|
||||||
let mut update_transform = || {
|
let mut update_transform = || {
|
||||||
let parent_global = self
|
let child = self.id();
|
||||||
.world()
|
let parent_global = self.world_scope(|world| {
|
||||||
.get_entity(parent)
|
world
|
||||||
.ok()?
|
.get_entity_mut(parent)
|
||||||
.get::<GlobalTransform>()?;
|
.ok()?
|
||||||
|
.add_child(child)
|
||||||
|
.get::<GlobalTransform>()
|
||||||
|
.copied()
|
||||||
|
})?;
|
||||||
let child_global = self.get::<GlobalTransform>()?;
|
let child_global = self.get::<GlobalTransform>()?;
|
||||||
let new_child_local = child_global.reparented_to(parent_global);
|
let new_child_local = child_global.reparented_to(&parent_global);
|
||||||
// TODO: Can this just be `self.insert(new_child_local)`? (does it matter if self doesn't already have `Transform`?)
|
// TODO: Can this just be `self.insert(new_child_local)`? (does it matter if self doesn't already have `Transform`?)
|
||||||
let mut child_local = self.get_mut::<Transform>()?;
|
let mut child_local = self.get_mut::<Transform>()?;
|
||||||
*child_local = new_child_local;
|
*child_local = new_child_local;
|
||||||
|
Loading…
Reference in New Issue
Block a user