
# Objective A lot of items in `bevy_ui` could be `FromReflect` but aren't. This prevents users and library authors from being able to convert from a `dyn Reflect` to one of these items. ## Solution Derive `FromReflect` where possible. Also register the `ReflectFromReflect` type data.
31 lines
973 B
Rust
31 lines
973 B
Rust
//! Configuration for cameras related to UI.
|
|
|
|
use bevy_ecs::component::Component;
|
|
use bevy_ecs::prelude::With;
|
|
use bevy_ecs::reflect::ReflectComponent;
|
|
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect, ReflectFromReflect};
|
|
use bevy_render::camera::Camera;
|
|
use bevy_render::extract_component::ExtractComponent;
|
|
|
|
/// Configuration for cameras related to UI.
|
|
///
|
|
/// When a [`Camera`] doesn't have the [`UiCameraConfig`] component,
|
|
/// it will display the UI by default.
|
|
///
|
|
#[derive(Component, Clone, ExtractComponent, Reflect, FromReflect)]
|
|
#[extract_component_filter(With<Camera>)]
|
|
#[reflect(Component, FromReflect, Default)]
|
|
pub struct UiCameraConfig {
|
|
/// Whether to output UI to this camera view.
|
|
///
|
|
/// When a [`Camera`] doesn't have the [`UiCameraConfig`] component,
|
|
/// it will display the UI by default.
|
|
pub show_ui: bool,
|
|
}
|
|
|
|
impl Default for UiCameraConfig {
|
|
fn default() -> Self {
|
|
Self { show_ui: true }
|
|
}
|
|
}
|