This commit is contained in:
JMS55 2023-12-05 22:37:16 -08:00
parent 65f5a625ad
commit e913daf07c

View file

@ -12,26 +12,24 @@ use dioxus_core::{Element, Mutations, Scope, ScopeState, VirtualDom};
use std::{cell::RefCell, mem::transmute, rc::Rc}; use std::{cell::RefCell, mem::transmute, rc::Rc};
pub fn tick_dioxus_ui(world: &mut World) { pub fn tick_dioxus_ui(world: &mut World) {
unsafe { let mut command_queue = CommandQueue::default();
let world_cell = world.as_unsafe_world_cell();
let apply_mutations = |mutations: Mutations, root_entity: Entity| { let apply_mutations = |mutations: Mutations, root_entity: Entity| {
todo!("Modify bevy_ui entities based on mutations"); todo!("Modify bevy_ui entities based on mutations");
}; };
let mut command_queue = CommandQueue::default(); let ecs_context = unsafe {
let ecs_context = EcsContext { EcsContext {
world_read_only: transmute(world_cell.world()), world_read_only: transmute(&world),
commands: Rc::new(RefCell::new(Commands::new( commands: Rc::new(RefCell::new(Commands::new(
transmute(&mut command_queue), transmute(&mut command_queue),
transmute(world_cell.world()), transmute(&world),
))), ))),
}
}; };
for (root_entity, mut dioxus_ui_root) in world_cell for (root_entity, mut dioxus_ui_root) in
.world_mut() world.query::<(Entity, &mut DioxusUiRoot)>().iter_mut(world)
.query::<(Entity, &mut DioxusUiRoot)>()
.iter_mut(world_cell.world_mut())
{ {
dioxus_ui_root dioxus_ui_root
.virtual_dom .virtual_dom
@ -58,7 +56,6 @@ pub fn tick_dioxus_ui(world: &mut World) {
command_queue.apply(world); command_queue.apply(world);
} }
}
#[derive(Clone)] #[derive(Clone)]
struct EcsContext { struct EcsContext {