Reflection for DepthOfFieldSettings (#14588)
				
					
				
			# Objective I can't mutate the dof settings via tools like `bevy_inspector_egui` ## Solution Add `Reflect` for `DepthOfFieldSettings` and `DepthOfFieldMode`
This commit is contained in:
		
							parent
							
								
									e6261b0f5f
								
							
						
					
					
						commit
						4c2cef2223
					
				| @ -21,10 +21,12 @@ use bevy_ecs::{ | |||||||
|     component::Component, |     component::Component, | ||||||
|     entity::Entity, |     entity::Entity, | ||||||
|     query::{QueryItem, With}, |     query::{QueryItem, With}, | ||||||
|  |     reflect::ReflectComponent, | ||||||
|     schedule::IntoSystemConfigs as _, |     schedule::IntoSystemConfigs as _, | ||||||
|     system::{lifetimeless::Read, Commands, Query, Res, ResMut, Resource}, |     system::{lifetimeless::Read, Commands, Query, Res, ResMut, Resource}, | ||||||
|     world::{FromWorld, World}, |     world::{FromWorld, World}, | ||||||
| }; | }; | ||||||
|  | use bevy_reflect::{prelude::ReflectDefault, Reflect}; | ||||||
| use bevy_render::{ | use bevy_render::{ | ||||||
|     camera::{PhysicalCameraParameters, Projection}, |     camera::{PhysicalCameraParameters, Projection}, | ||||||
|     extract_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin}, |     extract_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin}, | ||||||
| @ -67,7 +69,8 @@ const DOF_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(203186118073921 | |||||||
| pub struct DepthOfFieldPlugin; | pub struct DepthOfFieldPlugin; | ||||||
| 
 | 
 | ||||||
| /// Depth of field settings.
 | /// Depth of field settings.
 | ||||||
| #[derive(Component, Clone, Copy)] | #[derive(Component, Clone, Copy, Reflect)] | ||||||
|  | #[reflect(Component, Default)] | ||||||
| pub struct DepthOfFieldSettings { | pub struct DepthOfFieldSettings { | ||||||
|     /// The appearance of the effect.
 |     /// The appearance of the effect.
 | ||||||
|     pub mode: DepthOfFieldMode, |     pub mode: DepthOfFieldMode, | ||||||
| @ -110,7 +113,8 @@ pub struct DepthOfFieldSettings { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /// Controls the appearance of the effect.
 | /// Controls the appearance of the effect.
 | ||||||
| #[derive(Component, Clone, Copy, Default, PartialEq, Debug)] | #[derive(Component, Clone, Copy, Default, PartialEq, Debug, Reflect)] | ||||||
|  | #[reflect(Default, PartialEq)] | ||||||
| pub enum DepthOfFieldMode { | pub enum DepthOfFieldMode { | ||||||
|     /// A more accurate simulation, in which circles of confusion generate
 |     /// A more accurate simulation, in which circles of confusion generate
 | ||||||
|     /// "spots" of light.
 |     /// "spots" of light.
 | ||||||
| @ -195,6 +199,8 @@ impl Plugin for DepthOfFieldPlugin { | |||||||
|     fn build(&self, app: &mut App) { |     fn build(&self, app: &mut App) { | ||||||
|         load_internal_asset!(app, DOF_SHADER_HANDLE, "dof.wgsl", Shader::from_wgsl); |         load_internal_asset!(app, DOF_SHADER_HANDLE, "dof.wgsl", Shader::from_wgsl); | ||||||
| 
 | 
 | ||||||
|  |         app.register_type::<DepthOfFieldSettings>(); | ||||||
|  |         app.register_type::<DepthOfFieldMode>(); | ||||||
|         app.add_plugins(UniformComponentPlugin::<DepthOfFieldUniform>::default()); |         app.add_plugins(UniformComponentPlugin::<DepthOfFieldUniform>::default()); | ||||||
| 
 | 
 | ||||||
|         let Some(render_app) = app.get_sub_app_mut(RenderApp) else { |         let Some(render_app) = app.get_sub_app_mut(RenderApp) else { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Lixou
						Lixou