Skip to content

Allow user to choose the default ui camera #11377

@pablo-lua

Description

@pablo-lua

What problem does this solve or what need does it fill?

There is an example of a problem that this can lead in #11237, where we cannot spawn a new Camera in the same window as primary window without possible problems appearing (Debug camera interpolating with Ui camera)

What solution would you like?

  • The creation of a marker Component DefaultUiCamera (or a similar name: This name is already in use and can lead to conflicts), so when selecting the camera with a root entity that doesn't have TargetCamera, the DefaultCamera param will give priority to this component.

What alternative(s) have you considered?

  • The user, when creating a camera for debug purposes (Or another purposes that for now I don't know if exists), will have to add an TargetCamera for each root that exists (even though only one camera will load the Ui, the other Camera is created for another purposes) (This option Don't need the API Refactor)
  • Return with the UiCameraOptions, an component that marks if the Camera should show ui or not (I think we don't need this anymore)

Aditional Context

  • For now, say that you have two cameras spawned for PrimaryWindow -> The actual API will not return a warn or something, it will almost randomly pick one of the cameras. The camera depends on the camera order, the line is as follow:
    cameras: Query<'w, 's, (Entity, &'static Camera)>,

///...
self.cameras
    .iter()
    .filter(|(_, c)| match c.target {
        RenderTarget::Window(WindowRef::Primary) => true,
        RenderTarget::Window(WindowRef::Entity(w)) => self.primary_window.get(w).is_ok(),
        _ => false,
    })
    .max_by_key(|(e, c)| (c.order, *e))
    .map(|(e, _)| e)

but using the order can conflict if the user is building an debug camera (That generally will be above others)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsC-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions