Replies: 3 comments 1 reply
|
Any hint how this can be done with the current version? |
|
A bit late perhaps, but i still found this thread, and i have found an answer. (Works for v. 0.17.3) Lets say you have your render layers: pub const RENDER_LAYER_NETTVERK: usize = 0;
pub const RENDER_LAYER_ALLE_INDIVIDER: usize = 1;
pub const RENDER_LAYER_POPULASJON_MENY: usize = 2;You can then use the following system to adjust the render layer of gizmoes from the default 0, to 1. app.add_systems(Startup, update_gizmo_config);fn update_gizmo_config(
mut config_store: ResMut<GizmoConfigStore>,
) {
let (config, _) = config_store.config_mut::<DefaultGizmoConfigGroup>();
config.render_layers = RenderLayers::layer(RENDER_LAYER_ALLE_INDIVIDER);
}If it does not work in future versions, here are some hints on where to start investigating: GizmoConfig is the object that is holding the renderLayer. It is just an object. To modify it you retrieve it through the bevy-Resource GizmoConfigStore. (the type DefaultGizmoConfigGroup is just something that the config_mut function uses for what to give in the second argument it seems like. Not actual important in this case) https://idanarye.github.io/bevy-tnua/bevy_gizmos/config/struct.GizmoConfig.html |
|
This is how i'm currently drawing gizmos on multiple renderlayers for the same frame in 0.19.1: Define GizmoConfigGroups #[derive(Default, Reflect, GizmoConfigGroup)]
struct LayerA;
#[derive(Default, Reflect, GizmoConfigGroup)]
struct LayerB;initialize them (for example in app/plugin build method): app.init_gizmo_group::<LayerA>()
.init_gizmo_group::<LayerB>()
.add_systems(Update, draw_systems);
// Configure respective render layers
let mut config_store = app.world_mut().resource_mut::<GizmoConfigStore>();
let (config_a, _) = config_store.config_mut::<LayerA>();
config_a.render_layers = RenderLayers::layer(1);
let (config_b, _) = config_store.config_mut::<LayerB>();
config_b.render_layers = RenderLayers::layer(2);Then use them in a system: fn draw_systems(mut gizmos_a: Gizmos<LayerA>, mut gizmos_b: Gizmos<LayerB>) {
gizmos_a.line_2d(Vec2::ZERO, Vec2::X * 50.0, Color::WHITE);
gizmos_b.line_2d(Vec2::ZERO, Vec2::Y * 50.0, Color::WHITE);
} |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
If I have two cameras with different render layers and I want some gizmos to be rendered using one camera and some using another.
This obviously does not work. I need to commit some gizmos between systems.
And an additional question: is it possible to draw text in the same manner?
All reactions