#Render UI elements to Texture?

9 messages · Page 1 of 1 (latest)

silent gull
#

You can render all UI in one camera with texture output.

#

Meaning you'd atleast be able to create bendy floaty UI, though you'd have to figure out how to translate click location to the UI. :)

silent gull
#

Example on how to render UI to just one camera:

// Keep all cameras without UI by default
fn auto_config_cameras(
  query: Query<Entity, (With<Camera>, Without<UiCameraConfig>)>,
  commands: Commands
) {
  for entity in query.iter() {
    commands.entity(entity)
      .insert(UiCameraConfig {
        show_ui: false,
      });
  }
}

fn setup(
  mut commands: Commands,
  mut images: Assets<Image>,
) {
  // Spawn with Ui already on so it doesn't get auto disabled
  commands.spawn((
    Camera3dBundle::default(),
    UiCameraConfig {
      show_ui: true
    }
  ));
}
silent gull
#

You can seperate them into unrelated UI objects if you treat the texture as an atlas and change the texture mapping on the meshes to their respective rendered locations. You might be able to take advantage of flexbox to have it automatically place them and you extract it's size and location to update the meshes.

silent gull
#

It's the solution I could put together from what I am aware off, there might be better UI crates out there, feel free to ask in #ui if they know about a UI crate for VR

silent gull
#

Either way; you can make your own additions to the render loop and create your own UI system, you could probably take advantage of what's already made and adapt it to VR.

swift helm
#

@delicate cape Curious if you got this working to any degree -- also, was that your screenshot, casually hanging at Port Olisar with CS4? 😆