diff --git a/bin/editor.rs b/bin/editor.rs index 83b7c18..156ed59 100644 --- a/bin/editor.rs +++ b/bin/editor.rs @@ -39,7 +39,7 @@ const WELCOME_MESSAGES: &'static [&'static str] = &[ "* 3D: .gltf, .glb\n", "* Audio: .ogg\n", "* Font: .ttf, .otf\n", - "* Monologues: .monologue.txt\n", + "* Monologues: .monologue.txt", ), ]; @@ -748,11 +748,13 @@ mod scenes { current: Query<(Entity, &ui::TargetAsset)>, ) { events.iter().for_each(|event| { + let empty = current.iter().len() == 0; + match event { CustomAssetEvent::Add { name, handle } => { info!("Asset loading! {:?}({:?})", name, handle); // Spawn new tree - create_asset_button( + let e = create_asset_button( &widget, &mut commands, ui::TargetAsset { @@ -761,6 +763,10 @@ mod scenes { name.clone(), None, ); + // If this is the first scene being added, set it as active + if empty { + commands.entity(e).insert(ui::Active); + } } CustomAssetEvent::Remove { handle } => { destroy_asset_button( @@ -1158,14 +1164,20 @@ mod cameras { destroy_entity_button(¤t, &mut commands, &ui::TargetEntity { entity }); }); added.iter_mut().for_each(|(entity, mut camera, name)| { + let empty = current.iter().len() == 0; + info!("Camera added {:?} {:?}", entity, name); - create_entity_button( + let e = create_entity_button( &widget, &mut commands, ui::TargetEntity { entity }, name.as_str().into(), ); - camera.is_active = false; + if empty { + commands.entity(e).insert(ui::Active); + } else { + camera.is_active = false; + } }); }