chore(testing): added example of filtered out components

This commit is contained in:
kaosat.dev 2024-05-06 14:35:57 +02:00
parent 664e04b05c
commit 7e6805f221
2 changed files with 25 additions and 2 deletions

View File

@ -1,12 +1,23 @@
use bevy::prelude::*; use std::any::TypeId;
use bevy::{prelude::*, utils::HashSet};
use bevy_gltf_blueprints::*; use bevy_gltf_blueprints::*;
use bevy_registry_export::*; use bevy_registry_export::*;
use crate::{ComponentAToFilterOut, ComponentBToFilterOut};
pub struct CorePlugin; pub struct CorePlugin;
impl Plugin for CorePlugin { impl Plugin for CorePlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_plugins(( app.add_plugins((
ExportRegistryPlugin::default(), ExportRegistryPlugin{
component_filter: SceneFilter::Denylist(HashSet::from([ // this is using Bevy's build in SceneFilter, you can compose what components you want to allow/deny
TypeId::of::<ComponentAToFilterOut>(),
TypeId::of::<ComponentBToFilterOut>(),
// and any other commponent you want to include/exclude
])),
..Default::default()},
BlueprintsPlugin { BlueprintsPlugin {
library_folder: "blueprints".into(), library_folder: "blueprints".into(),
format: GltfFormat::GLB, format: GltfFormat::GLB,

View File

@ -189,6 +189,15 @@ pub struct HashmapTestStringColor {
#[reflect(Component)] #[reflect(Component)]
pub struct HashmapTestStringColorFlat(HashMap<String, Color>); pub struct HashmapTestStringColorFlat(HashMap<String, Color>);
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
pub struct ComponentAToFilterOut;
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
pub struct ComponentBToFilterOut;
pub struct ComponentsTestPlugin; pub struct ComponentsTestPlugin;
impl Plugin for ComponentsTestPlugin { impl Plugin for ComponentsTestPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
@ -236,6 +245,9 @@ impl Plugin for ComponentsTestPlugin {
.register_type::<HashmapTestStringColor>() .register_type::<HashmapTestStringColor>()
.register_type::<HashmapTestStringColorFlat>() .register_type::<HashmapTestStringColorFlat>()
.register_type::<ComponentAToFilterOut>()
.register_type::<ComponentBToFilterOut>()
.add_plugins(MaterialPlugin::< .add_plugins(MaterialPlugin::<
ExtendedMaterial<StandardMaterial, MyExtension>, ExtendedMaterial<StandardMaterial, MyExtension>,
>::default()); >::default());