如何解决如何在使用 commands.spawn_bundle() 生成的 bevy 0.5.0 中消除实体
这是一个非常简单的问题。 我已经重写了我的代码以处理新版本 bevy 带来的语法和其他更改。
编译时似乎一切正常,除了实体的消失。
我在上述实体中生成,例如:
commands.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),material: builder_texture.clone(),transform: Transform::from_matrix(Mat4::from_scale_rotation_translation(
Vec3::splat(0.75),Quat::from_rotation_x(0.0),Vec3::new(0.0,0.0,0.0),)),..Default::default()
})
.insert(controll::BuilderIndicator);
但我无法像这样让它消失:
fn despawn(
mut entity: Query<(Entity,controll::BuilderIndicator),With<controll::BuilderIndicator>>,mut commands: Commands,) {
for (entity,example) in entity.iter_mut() {
commands.despawn(entity);
}
}
它返回:
error[E0599]: no method named `despawn` found for struct `bevy::prelude::Commands<'_>` in the current scope
--> src/controll.rs:120:26
|
120 | commands.despawn(entity);
| ^^^^^^^ help: there is an associated function with a similar name: `spawn`
error: aborting due to previous error
我需要做什么才能让它发挥作用?
解决方法
似乎有些方法已移至EntityCommands。
所以你必须这样做:
commands.entity(entity).despawn();
我还没有测试。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。