Replies: 1 comment 3 replies
-
pub fn get_player_component_system<Q: QueryData>(
In(player_name): In<impl Into<String>>,
query: Query<(&Q, &Name), With<Player>>,
) -> Option<&Q> {
let pname = player_name.into();
query.iter().find_map(|(data, name)| {
if pname == name.to_string() {
Some(data)
} else {
None
}
})
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to do something like the following function, but not sure to what extend this is possible or even makes sense (as
QueryData
is not public):This is very similar to a non-generic implementation that does work, for instance:
Beta Was this translation helpful? Give feedback.
All reactions