Blender_bevy_components_wor.../examples/advanced/test_components.rs

81 lines
2.0 KiB
Rust
Raw Normal View History

use bevy::prelude::*;
2023-10-13 10:53:26 +00:00
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
struct UnitTest;
#[derive(Component, Reflect, Default, Debug, Deref, DerefMut)]
#[reflect(Component)]
struct TuppleTestF32(f32);
#[derive(Component, Reflect, Default, Debug, Deref, DerefMut)]
#[reflect(Component)]
struct TuppleTestU64(u64);
#[derive(Component, Reflect, Default, Debug, Deref, DerefMut)]
#[reflect(Component)]
pub struct TuppleTestStr(String);
2023-10-13 10:53:26 +00:00
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
struct TuppleTest2(f32, u64, String);
2023-10-13 10:53:26 +00:00
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
struct TuppleTestBool(bool);
2023-10-13 10:53:26 +00:00
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
struct TuppleVec2(Vec2);
2023-10-13 10:53:26 +00:00
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
struct TuppleVec3(Vec3);
2023-10-13 10:53:26 +00:00
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
struct TuppleVec(Vec<String>);
2023-10-13 10:53:26 +00:00
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
struct TuppleTestColor(Color);
2023-10-13 10:53:26 +00:00
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
2023-10-13 10:53:26 +00:00
struct BasicTest {
a: f32,
b: u64,
2023-10-13 10:53:26 +00:00
c: String,
}
2023-10-13 10:53:26 +00:00
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
2023-10-13 10:53:26 +00:00
pub enum EnumTest {
Metal,
Wood,
Rock,
Cloth,
Squishy,
#[default]
None,
}
pub struct ComponentsTestPlugin;
impl Plugin for ComponentsTestPlugin {
2023-10-13 10:53:26 +00:00
fn build(&self, app: &mut App) {
app.register_type::<BasicTest>()
.register_type::<UnitTest>()
.register_type::<TuppleTestF32>()
.register_type::<TuppleTestU64>()
.register_type::<TuppleTestStr>()
.register_type::<TuppleTestBool>()
.register_type::<TuppleTest2>()
.register_type::<TuppleVec2>()
.register_type::<TuppleVec3>()
.register_type::<EnumTest>()
.register_type::<TuppleTestColor>()
.register_type::<TuppleVec>()
.register_type::<Vec<String>>();
}
}