bevy/crates/bevy_ui/src/camera_config.rs
Gino Valente 85c3251c10
bevy_ui: Add FromReflect derives (#8495)
# 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.
2023-04-26 12:17:23 +00:00

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 }
}
}