mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-22 11:50:53 +00:00
feat():
* cleaned up crate code * added duplicate named component to testing project to resolve issues with clashing short_names for bevy components
This commit is contained in:
parent
9138c81c60
commit
49917e3b17
@ -10,13 +10,7 @@ pub use process_gltfs::*;
|
||||
pub mod blender_settings;
|
||||
|
||||
use bevy::{
|
||||
app::Startup,
|
||||
ecs::{
|
||||
component::Component,
|
||||
reflect::ReflectComponent,
|
||||
system::{Res, Resource},
|
||||
},
|
||||
log::warn,
|
||||
ecs::{component::Component, reflect::ReflectComponent, system::Resource},
|
||||
prelude::{App, IntoSystemConfigs, Plugin, SystemSet, Update},
|
||||
reflect::Reflect,
|
||||
};
|
||||
@ -68,16 +62,14 @@ pub enum GltfComponentsSet {
|
||||
#[derive(Clone, Resource)]
|
||||
pub struct GltfComponentsConfig {}
|
||||
|
||||
pub struct ComponentsFromGltfPlugin {
|
||||
}
|
||||
pub struct ComponentsFromGltfPlugin {}
|
||||
|
||||
impl Default for ComponentsFromGltfPlugin {
|
||||
fn default() -> Self {
|
||||
Self { }
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Plugin for ComponentsFromGltfPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugins(blender_settings::plugin)
|
||||
|
@ -13,7 +13,7 @@ use bevy::{
|
||||
utils::HashMap,
|
||||
};
|
||||
|
||||
use crate::{ronstring_to_reflect_component, GltfComponentsConfig, GltfProcessed};
|
||||
use crate::{ronstring_to_reflect_component, GltfProcessed};
|
||||
|
||||
/// main function: injects components into each entity in gltf files that have `gltf_extras`, using reflection
|
||||
pub fn add_components_from_gltf_extras(world: &mut World) {
|
||||
@ -22,7 +22,7 @@ pub fn add_components_from_gltf_extras(world: &mut World) {
|
||||
let mut entity_components: HashMap<Entity, Vec<(Box<dyn Reflect>, TypeRegistration)>> =
|
||||
HashMap::new();
|
||||
|
||||
let gltf_components_config = world.resource::<GltfComponentsConfig>();
|
||||
// let gltf_components_config = world.resource::<GltfComponentsConfig>();
|
||||
|
||||
for (entity, name, extra, parent) in extras.iter(world) {
|
||||
debug!(
|
||||
@ -33,10 +33,7 @@ pub fn add_components_from_gltf_extras(world: &mut World) {
|
||||
let type_registry: &AppTypeRegistry = world.resource();
|
||||
let type_registry = type_registry.read();
|
||||
|
||||
let reflect_components = ronstring_to_reflect_component(
|
||||
&extra.value,
|
||||
&type_registry,
|
||||
);
|
||||
let reflect_components = ronstring_to_reflect_component(&extra.value, &type_registry);
|
||||
|
||||
// we assign the components specified /xxx_components objects to their parent node
|
||||
let mut target_entity = entity;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use bevy::log::{debug, warn};
|
||||
use bevy::reflect::serde::UntypedReflectDeserializer;
|
||||
use bevy::reflect::{Reflect, TypeInfo, TypeRegistration, TypeRegistry};
|
||||
use bevy::reflect::{Reflect, TypeRegistration, TypeRegistry};
|
||||
use bevy::utils::HashMap;
|
||||
use ron::Value;
|
||||
use serde::de::DeserializeSeed;
|
||||
@ -17,7 +17,7 @@ pub fn ronstring_to_reflect_component(
|
||||
let type_string = key.replace("component: ", "").trim().to_string();
|
||||
let capitalized_type_name = capitalize_first_letter(type_string.as_str());
|
||||
|
||||
let mut parsed_value: String;
|
||||
let parsed_value: String;
|
||||
match value.clone() {
|
||||
Value::String(str) => {
|
||||
parsed_value = str;
|
||||
|
@ -2960,6 +2960,22 @@
|
||||
"type": "object",
|
||||
"typeInfo": "Struct"
|
||||
},
|
||||
"bevy_example::dupe_components::EnumTest": {
|
||||
"isComponent": true,
|
||||
"isResource": false,
|
||||
"oneOf": [
|
||||
"Metal",
|
||||
"Wood",
|
||||
"Rock",
|
||||
"Cloth",
|
||||
"Squishy",
|
||||
"None"
|
||||
],
|
||||
"short_name": "EnumTest",
|
||||
"title": "bevy_example::dupe_components::EnumTest",
|
||||
"type": "string",
|
||||
"typeInfo": "Enum"
|
||||
},
|
||||
"bevy_example::game::animation::Marker1": {
|
||||
"additionalProperties": false,
|
||||
"isComponent": true,
|
||||
|
13
testing/bevy_example/src/dupe_components/mod.rs
Normal file
13
testing/bevy_example/src/dupe_components/mod.rs
Normal file
@ -0,0 +1,13 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
#[derive(Component, Reflect, Default, Debug)]
|
||||
#[reflect(Component)]
|
||||
pub enum EnumTest {
|
||||
Metal,
|
||||
Wood,
|
||||
Rock,
|
||||
Cloth,
|
||||
Squishy,
|
||||
#[default]
|
||||
None,
|
||||
}
|
@ -7,6 +7,7 @@ use crate::core::*;
|
||||
mod game;
|
||||
use game::*;
|
||||
|
||||
mod dupe_components;
|
||||
mod test_components;
|
||||
use test_components::*;
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::dupe_components;
|
||||
use bevy::{
|
||||
pbr::{ExtendedMaterial, MaterialExtension},
|
||||
prelude::*,
|
||||
@ -164,6 +165,7 @@ impl Plugin for ComponentsTestPlugin {
|
||||
.register_type::<TupleVec2>()
|
||||
.register_type::<TupleVec3>()
|
||||
.register_type::<EnumTest>()
|
||||
.register_type::<dupe_components::EnumTest>()
|
||||
.register_type::<TupleTestColor>()
|
||||
.register_type::<TupleVec>()
|
||||
.register_type::<Vec<String>>()
|
||||
|
Loading…
Reference in New Issue
Block a user