Bugfixes
This commit is contained in:
parent
74e9fecc0f
commit
53f3756a66
|
@ -26,6 +26,7 @@ fn main() {
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
fn Editor(cx: Scope) -> Element {
|
fn Editor(cx: Scope) -> Element {
|
||||||
|
// TODO: When selected entity is despawned, need to reset this to None
|
||||||
let selected_entity = use_state(cx, || Option::<Entity>::None);
|
let selected_entity = use_state(cx, || Option::<Entity>::None);
|
||||||
|
|
||||||
render! {
|
render! {
|
||||||
|
@ -43,6 +44,7 @@ fn SceneTree<'a>(cx: Scope, selected_entity: &'a UseState<Option<Entity>>) -> El
|
||||||
|
|
||||||
render! {
|
render! {
|
||||||
div {
|
div {
|
||||||
|
onclick: move |_| selected_entity.set(None),
|
||||||
flex_direction: "column",
|
flex_direction: "column",
|
||||||
if entities.is_empty() {
|
if entities.is_empty() {
|
||||||
rsx! { "No entities exist" }
|
rsx! { "No entities exist" }
|
||||||
|
|
|
@ -4,9 +4,10 @@ use bevy::{
|
||||||
hierarchy::{BuildWorldChildren, Children, DespawnRecursive, Parent},
|
hierarchy::{BuildWorldChildren, Children, DespawnRecursive, Parent},
|
||||||
prelude::default,
|
prelude::default,
|
||||||
render::color::Color,
|
render::color::Color,
|
||||||
text::{Text, TextStyle},
|
text::{Text, TextLayoutInfo, TextStyle},
|
||||||
ui::{
|
ui::{
|
||||||
node_bundles::{NodeBundle, TextBundle},
|
node_bundles::{NodeBundle, TextBundle},
|
||||||
|
widget::TextFlags,
|
||||||
*,
|
*,
|
||||||
},
|
},
|
||||||
utils::{EntityHashMap, HashMap},
|
utils::{EntityHashMap, HashMap},
|
||||||
|
@ -62,9 +63,12 @@ pub fn apply_mutations(
|
||||||
for index in path {
|
for index in path {
|
||||||
entity = world.entity(entity).get::<Children>().unwrap()[*index as usize];
|
entity = world.entity(entity).get::<Children>().unwrap()[*index as usize];
|
||||||
}
|
}
|
||||||
world
|
world.entity_mut(entity).insert((
|
||||||
.entity_mut(entity)
|
Text::from_section(value, TextStyle::default()),
|
||||||
.insert(Text::from_section(value, TextStyle::default()));
|
TextLayoutInfo::default(),
|
||||||
|
TextFlags::default(),
|
||||||
|
ContentSize::default(),
|
||||||
|
));
|
||||||
element_id_to_bevy_ui_entity.insert(id, entity);
|
element_id_to_bevy_ui_entity.insert(id, entity);
|
||||||
bevy_ui_entity_to_element_id.insert(entity, id);
|
bevy_ui_entity_to_element_id.insert(entity, id);
|
||||||
}
|
}
|
||||||
|
@ -93,6 +97,7 @@ pub fn apply_mutations(
|
||||||
existing_parent.insert_children(existing_index, &new);
|
existing_parent.insert_children(existing_index, &new);
|
||||||
|
|
||||||
DespawnRecursive { entity: existing }.apply(world);
|
DespawnRecursive { entity: existing }.apply(world);
|
||||||
|
// TODO: We're not removing child entities from the element maps
|
||||||
if let Some(existing_element_id) = bevy_ui_entity_to_element_id.remove(&existing) {
|
if let Some(existing_element_id) = bevy_ui_entity_to_element_id.remove(&existing) {
|
||||||
element_id_to_bevy_ui_entity.remove(&existing_element_id);
|
element_id_to_bevy_ui_entity.remove(&existing_element_id);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +187,7 @@ impl BevyTemplateNode {
|
||||||
Self::TextNode(Text::from_section(*text, TextStyle::default()))
|
Self::TextNode(Text::from_section(*text, TextStyle::default()))
|
||||||
}
|
}
|
||||||
TemplateNode::Dynamic { id: _ } => Self::Node {
|
TemplateNode::Dynamic { id: _ } => Self::Node {
|
||||||
style: Default::default(),
|
style: (Style::default(), Color::NONE.into()),
|
||||||
children: Box::new([]),
|
children: Box::new([]),
|
||||||
},
|
},
|
||||||
TemplateNode::DynamicText { id: _ } => {
|
TemplateNode::DynamicText { id: _ } => {
|
||||||
|
|
Loading…
Reference in a new issue