From 1963c290a10747dc2d8611b5df0a8e642146bbc6 Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Fri, 8 Sep 2023 17:41:13 -0700 Subject: [PATCH] there are bugs, taking a break to do work on timeline --- bin/editor.rs | 58 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/bin/editor.rs b/bin/editor.rs index 62c802f..623bfd7 100644 --- a/bin/editor.rs +++ b/bin/editor.rs @@ -6,18 +6,6 @@ // * When Handle is loaded, the button for TargetAsset should load as well // * Exported level should preserve active camera // * Picking new GLTF resets audio without resetting buttons -// * Error with exported scene w/ animation: -// WARN bevy_asset::asset_server: encountered an error while loading an asset: -// no registration found for type -// `alloc::vec::Vec< -// alloc::vec::Vec< -// core::option::Option< -// bevy_ecs::entity::Entity -// >>>` -// at output.scn.ron:723:23 -// This is the `path_cache` field on an Animation -// ... -// Also many other components out of the box just straight up don't work... // // TODO: // * edit textbox with actions @@ -31,7 +19,6 @@ use bevy::{ asset::{Asset, AssetLoader, Assets, ChangeWatcher, LoadContext, LoadedAsset}, audio::PlaybackMode, - core_pipeline::tonemapping::DebandDither, gltf::Gltf, prelude::*, utils::{BoxedFuture, Duration}, @@ -135,6 +122,18 @@ fn main() { //rehydrate_level::, ), ) + .add_systems( + Update, + ( + sync_asset_buttons::, + sync_asset_buttons::, + sync_asset_buttons::, + sync_asset_buttons::, + sync_asset_buttons::, + sync_asset_buttons::, + sync_asset_buttons::, + ), + ) .run(); } @@ -1472,7 +1471,7 @@ mod level { use super::*; - type Level = DynamicScene; + pub type Level = DynamicScene; #[derive(Debug, Component, Default)] pub struct LevelWidget; @@ -1645,3 +1644,34 @@ mod quit { exit.send(AppExit); } } + +use asset_sync::*; +mod asset_sync { + use super::*; + + // This sets buttons to active when their associated handle is spawned + // TODO: Remove active when handle is despawned? + // ONLY IF there are no instances of that handle [!any(*)] + pub fn sync_asset_buttons( + events: Query<&Handle, Added>>, + buttons: Query<(Entity, &ui::TargetAsset)>, + mut commands: Commands, + ) { + events.iter().for_each(|this_handle| { + info!("Syncing {:?}", this_handle); + buttons + .iter() + .find_map(|(entity, ui::TargetAsset { handle })| { + if handle == this_handle { + Some(entity) + } else { + None + } + }) + .iter() + .for_each(|&entity| { + commands.entity(entity).insert(ui::Active); + }); + }); + } +}