@@ -725,7 +725,12 @@ pub fn conditional_render_set<S: SystemSet + Clone, M>(
725
725
}
726
726
} ) ;
727
727
render_app
728
- . add_systems ( RenderStartup , condition. before ( system_set. clone ( ) ) )
728
+ . add_systems (
729
+ RenderStartup ,
730
+ condition
731
+ . in_set ( ConditionalRenderSetCondition :: < S > ( PhantomData ) )
732
+ . before ( system_set. clone ( ) ) ,
733
+ )
729
734
. configure_sets (
730
735
RenderStartup ,
731
736
system_set
@@ -743,3 +748,39 @@ pub fn conditional_render_set<S: SystemSet + Clone, M>(
743
748
system_set. run_if ( resource_exists :: < EnabledRenderSet < S > > ) ,
744
749
) ;
745
750
}
751
+
752
+ /// A system set for the condition used in `conditional_render_set`.
753
+ ///
754
+ /// This allows the condition to be ordered after its dependencies for example.
755
+ #[ derive( SystemSet ) ]
756
+ pub struct ConditionalRenderSetCondition < S : SystemSet > ( pub PhantomData < fn ( ) -> S > ) ;
757
+
758
+ // Manual impls of SystemSet required traits to prevent needing `S` to implement those traits.
759
+
760
+ impl < S : SystemSet > Clone for ConditionalRenderSetCondition < S > {
761
+ fn clone ( & self ) -> Self {
762
+ Self ( self . 0 . clone ( ) )
763
+ }
764
+ }
765
+
766
+ impl < S : SystemSet > core:: fmt:: Debug for ConditionalRenderSetCondition < S > {
767
+ fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
768
+ f. debug_tuple ( "ConditionalRenderSetCondition" )
769
+ . field ( & self . 0 )
770
+ . finish ( )
771
+ }
772
+ }
773
+
774
+ impl < S : SystemSet > core:: hash:: Hash for ConditionalRenderSetCondition < S > {
775
+ fn hash < H : core:: hash:: Hasher > ( & self , state : & mut H ) {
776
+ self . 0 . hash ( state) ;
777
+ }
778
+ }
779
+
780
+ impl < S : SystemSet > Eq for ConditionalRenderSetCondition < S > { }
781
+
782
+ impl < S : SystemSet > PartialEq for ConditionalRenderSetCondition < S > {
783
+ fn eq ( & self , other : & Self ) -> bool {
784
+ self . 0 == other. 0
785
+ }
786
+ }
0 commit comments