-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SystemParamBuilder - Support dynamic system parameters (#14817)
# Objective Support building systems with parameters whose types can be determined at runtime. ## Solution Create a `DynSystemParam` type that can be built using a `SystemParamBuilder` of any type and then downcast to the appropriate type dynamically. ## Example ```rust let system = ( DynParamBuilder::new(LocalBuilder(3_usize)), DynParamBuilder::new::<Query<()>>(QueryParamBuilder::new(|builder| { builder.with::<A>(); })), DynParamBuilder::new::<&Entities>(ParamBuilder), ) .build_state(&mut world) .build_system( |mut p0: DynSystemParam, mut p1: DynSystemParam, mut p2: DynSystemParam| { let local = p0.downcast_mut::<Local<usize>>().unwrap(); let query_count = p1.downcast_mut::<Query<()>>().unwrap(); let entities = p2.downcast_mut::<&Entities>().unwrap(); }, ); ``` --------- Co-authored-by: Alice Cecile <[email protected]> Co-authored-by: Periwink <[email protected]>
- Loading branch information
1 parent
94d40d2
commit 335f290
Showing
2 changed files
with
307 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters