在具有以下场景文件的Bevymy_scene.scn
项目中:
[
(
entity: 0,
components: [
{
"type": "Transform",
"map": {
"translation": {
"type": "Vec3",
"value": (150.0, 200.0, 0.0),
},
"rotation": {
"type": "Quat",
"value": (0.0, 0.0, 0.0, 1.0),
},
"scale": {
"type": "Vec3",
"value": (0.75, 0.75, 0.0),
},
},
},
]
)
]
并使用此官方 Bevy 示例之后的源代码:
use bevy::prelude::*;
fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_startup_system(load_scene_system.system())
.run();
}
fn load_scene_system(asset_server: Res<AssetServer>, mut scene_spawner: ResMut<SceneSpawner>) {
let scene_handle: Handle<Scene> = asset_server.load("my_scene.scn");
scene_spawner.spawn_dynamic(scene_handle);
// ^ How to add components to entities created here ?
asset_server.watch_for_changes().unwrap();
}
我想向该实体 0 添加其他组件,例如SpriteComponents
. 我如何实现这一目标?