diff --git a/studio/src/interaction/selection.rs b/studio/src/interaction/selection.rs index 985fd2e..ca7acad 100644 --- a/studio/src/interaction/selection.rs +++ b/studio/src/interaction/selection.rs @@ -53,7 +53,8 @@ impl Plugin for SelectionPlugin { } } -#[derive(Component, Clone, Copy)] +#[derive(Component, Clone, Copy, Reflect, Default)] +#[reflect(Component, Default)] pub struct Selectable; #[derive(Resource, Deref, DerefMut, Debug)] @@ -101,17 +102,19 @@ fn propagate_space_editor_to_studio( fn tag_scene_elements( mut cmd: Commands, - q_scene_elements: Query<(Entity, &Children), (With, Without)>, + q_scene_elements: Query<(Entity, Option<&Children>), (With, Without)>, q_primitives: Query<&Handle>, ) { for (ent, children) in q_scene_elements.iter() { - cmd.entity(ent).insert(Selectable); + cmd.entity(ent).insert(Selectable).insert(PickableBundle::default()); - for &ent_child in children - .iter() - .filter(|child| q_primitives.contains(**child)) - { - cmd.entity(ent_child).insert(PickableBundle::default()); + if let Some(children) = children { + for &ent_child in children + .iter() + .filter(|child| q_primitives.contains(**child)) + { + cmd.entity(ent_child).insert(PickableBundle::default()); + } } } } diff --git a/studio/src/scene.rs b/studio/src/scene.rs index 3b51f3d..cf86f2d 100644 --- a/studio/src/scene.rs +++ b/studio/src/scene.rs @@ -17,22 +17,14 @@ use bevy::{ use serde_repr::{Deserialize_repr, Serialize_repr}; use space_editor::{ prelude::{EditorEvent, EditorPrefabPath, PrefabMarker}, - space_prefab::component::{GltfPrefab, SceneAutoChild}, + space_prefab::{component::{GltfPrefab, SceneAutoChild}, editor_registry::EditorRegistryExt}, }; #[cfg(feature = "wasm")] use wasm_bindgen::prelude::wasm_bindgen; use wgpu::{TextureDescriptor, TextureUsages}; use crate::{ - anim::timeline_animation::AnimationTarget, - camera_controller::{CameraController, CameraControllerBundle}, - change_tracking::{ChangeTracker, ChangeTrackingPlugin}, - debug::DebugPoint, - headless::{is_headless, is_not_headless, HeadlessSettings}, - is_editor, - math::{Combinable, Extrema}, - screenshot::ScreenCapture, - MainCamera, + anim::timeline_animation::AnimationTarget, camera_controller::{CameraController, CameraControllerBundle}, change_tracking::{ChangeTracker, ChangeTrackingPlugin}, debug::DebugPoint, headless::{is_headless, is_not_headless, HeadlessSettings}, interaction::Selectable, is_editor, math::{Combinable, Extrema}, screenshot::ScreenCapture, MainCamera }; pub struct ScenePlugin; @@ -109,6 +101,9 @@ impl Plugin for ScenePlugin { wasm::notify_loading_queue_changes.map(bevy::utils::error), ), ); + + app.editor_registry::(); + // app.editor_registry::(); } } @@ -253,9 +248,11 @@ pub struct ImportSceneEvent(pub String); wasm_bindgen, derive(Serialize_repr, Deserialize_repr) )] -#[derive(Component, Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Component, Clone, Copy, Debug, PartialEq, Eq, Reflect, Default)] +#[reflect(Component, Default)] #[allow(dead_code)] // Some variants only used in `wasm`, some planned for later use pub enum SceneElement { + #[default] Generic, Mesh, Skeleton, diff --git a/studio/src/ui/blocking.rs b/studio/src/ui/blocking.rs index b32a766..5b1fc77 100644 --- a/studio/src/ui/blocking.rs +++ b/studio/src/ui/blocking.rs @@ -30,9 +30,7 @@ fn read_command_system(mut commands: Commands, mut change_event: EventWriter