Path: blob/main/crates/bevy_ecs/src/reflect/resource.rs
9408 views
//! Definitions for [`Resource`] reflection.1//!2//! # Architecture3//!4//! See the module doc for [`reflect::component`](`crate::reflect::component`).56use crate::{reflect::ReflectComponent, resource::Resource};7use bevy_reflect::{FromReflect, FromType, TypePath, TypeRegistration};89/// A struct that marks a reflected [`Resource`] of a type.10///11/// This is struct does not provide any functionality.12/// It implies the existence of a reflected [`Component`](crate::component::Component) of the same type,13/// which is meant to be used instead.14///15/// ```rust,ignore16/// #[derive(Resource, Reflect)]17/// #[reflect(Resource)]18/// struct ResA;19///20/// // is the same as:21///22/// #[derive(Resource, Component, Reflect)]23/// #[reflect(Resource, Component)]24/// struct ResA;25/// ```26///27/// A [`ReflectResource`] for type `T` can be obtained via28/// [`bevy_reflect::TypeRegistration::data`].29#[derive(Clone)]30pub struct ReflectResource;3132impl<R: Resource + FromReflect + TypePath> FromType<R> for ReflectResource {33fn from_type() -> Self {34ReflectResource35}3637fn insert_dependencies(type_registration: &mut TypeRegistration) {38type_registration.register_type_data::<ReflectComponent, R>();39}40}414243