Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_scene/src/components.rs
6849 views
1
use bevy_asset::{AsAssetId, AssetId, Handle};
2
use bevy_derive::{Deref, DerefMut};
3
use bevy_ecs::{component::Component, prelude::ReflectComponent};
4
use bevy_reflect::{prelude::ReflectDefault, Reflect};
5
use bevy_transform::components::Transform;
6
use derive_more::derive::From;
7
8
use bevy_camera::visibility::Visibility;
9
10
use crate::{DynamicScene, Scene};
11
12
/// Adding this component will spawn the scene as a child of that entity.
13
/// Once it's spawned, the entity will have a [`SceneInstance`](crate::SceneInstance) component.
14
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect, PartialEq, Eq, From)]
15
#[reflect(Component, Default, Debug, PartialEq, Clone)]
16
#[require(Transform)]
17
#[require(Visibility)]
18
pub struct SceneRoot(pub Handle<Scene>);
19
20
impl AsAssetId for SceneRoot {
21
type Asset = Scene;
22
23
fn as_asset_id(&self) -> AssetId<Self::Asset> {
24
self.id()
25
}
26
}
27
28
/// Adding this component will spawn the scene as a child of that entity.
29
/// Once it's spawned, the entity will have a [`SceneInstance`](crate::SceneInstance) component.
30
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect, PartialEq, Eq, From)]
31
#[reflect(Component, Default, Debug, PartialEq, Clone)]
32
#[require(Transform)]
33
#[require(Visibility)]
34
pub struct DynamicSceneRoot(pub Handle<DynamicScene>);
35
36
impl AsAssetId for DynamicSceneRoot {
37
type Asset = DynamicScene;
38
39
fn as_asset_id(&self) -> AssetId<Self::Asset> {
40
self.id()
41
}
42
}
43
44