@@ -10,10 +10,10 @@ use derive_more::derive::{Deref, DerefMut};
1010pub use range:: * ;
1111pub use render_layers:: * ;
1212
13- use bevy_app:: { Plugin , PostUpdate } ;
13+ use bevy_app:: { Plugin , PostUpdate , ValidateParentHasComponentPlugin } ;
1414use bevy_asset:: prelude:: AssetChanged ;
1515use bevy_asset:: { AssetEventSystems , Assets } ;
16- use bevy_ecs:: { hierarchy :: validate_parent_has_component , prelude:: * } ;
16+ use bevy_ecs:: prelude:: * ;
1717use bevy_reflect:: { std_traits:: ReflectDefault , Reflect } ;
1818use bevy_transform:: { components:: GlobalTransform , TransformSystems } ;
1919use bevy_utils:: { Parallel , TypeIdMap } ;
@@ -113,7 +113,6 @@ impl PartialEq<&Visibility> for Visibility {
113113/// [`VisibilityPropagate`]: VisibilitySystems::VisibilityPropagate
114114#[ derive( Component , Deref , Debug , Default , Clone , Copy , Reflect , PartialEq , Eq ) ]
115115#[ reflect( Component , Default , Debug , PartialEq , Clone ) ]
116- #[ component( on_insert = validate_parent_has_component:: <Self >) ]
117116pub struct InheritedVisibility ( bool ) ;
118117
119118impl InheritedVisibility {
@@ -394,7 +393,8 @@ impl Plugin for VisibilityPlugin {
394393 fn build ( & self , app : & mut bevy_app:: App ) {
395394 use VisibilitySystems :: * ;
396395
397- app. register_required_components :: < Mesh3d , Visibility > ( )
396+ app. add_plugins ( ValidateParentHasComponentPlugin :: < InheritedVisibility > :: default ( ) )
397+ . register_required_components :: < Mesh3d , Visibility > ( )
398398 . register_required_components :: < Mesh3d , VisibilityClass > ( )
399399 . register_required_components :: < Mesh2d , Visibility > ( )
400400 . register_required_components :: < Mesh2d , VisibilityClass > ( )
0 commit comments