Skip to content

Commit

Permalink
Merge pull request #69 from Umatriz/custom_gizmo_config
Browse files Browse the repository at this point in the history
Add ability to provide a custom gizmos config
  • Loading branch information
IDEDARY authored Sep 7, 2024
2 parents 8ba2597 + ec04348 commit d7d1992
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions crates/bevy_lunex/src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ pub fn compute_ui<T:Component, N:Default + Component>(
/// * Generic `(M)` - Master data schema struct defining what can be stored in [`UiTree`]
/// * Generic `(N)` - Node data schema struct defining what can be stored in [`UiNode`]
/// * Generic `(T)` - Marker component grouping entities into one widget type
pub fn debug_draw_gizmo<T:Component, N:Default + Component>(
/// * Generic `(G)` - `GizmoConfigGroup` that will be used to draw the outlines
pub fn debug_draw_gizmo<T:Component, N:Default + Component, G:GizmoConfigGroup>(
mut query: Query<(&UiTree<T, N>, &GlobalTransform)>,
mut gizmos: Gizmos
mut gizmos: Gizmos<G>
) {
for (tree, transform) in &mut query {
let list = tree.crawl();
Expand Down Expand Up @@ -629,16 +630,16 @@ impl <T:Component, N:Default + Component> Plugin for UiGenericPlugin<T, N> {
///# }
/// ```
#[derive(Debug, Default, Clone)]
pub struct UiDebugPlugin <T:Component = MainUi, N:Default + Component = NoData>(PhantomData<T>, PhantomData<N>);
impl <T:Component, N:Default + Component> UiDebugPlugin<T, N> {
pub struct UiDebugPlugin <T:Component = MainUi, N:Default + Component = NoData, G:GizmoConfigGroup = DefaultGizmoConfigGroup>(PhantomData<T>, PhantomData<N>, PhantomData<G>);
impl <T:Component, N:Default + Component, G:GizmoConfigGroup> UiDebugPlugin<T, N, G> {
pub fn new() -> Self {
UiDebugPlugin::<T, N>(PhantomData, PhantomData)
UiDebugPlugin::<T, N, G>(PhantomData, PhantomData, PhantomData)
}
}
impl <T:Component, N:Default + Component> Plugin for UiDebugPlugin<T, N> {
impl <T:Component, N:Default + Component, G:GizmoConfigGroup> Plugin for UiDebugPlugin<T, N, G> {
fn build(&self, app: &mut App) {
app
.add_systems(Update, debug_draw_gizmo::<T, N>)
.add_systems(Update, debug_draw_gizmo::<T, N, G>)
.add_systems(Update, debug_print_tree::<T, N>.after(UiSystems::Compute));
}
}

0 comments on commit d7d1992

Please sign in to comment.