Wrong command called problem!
Closed this issue · 7 comments
zzhgithub commented
zzhgithub commented
Here are codes:
impl Plugin for ConsoleCommandPlugins {
fn build(&self, app: &mut App) {
app.add_plugins(ConsolePlugin)
.add_systems(PreUpdate, sync_flags)
.add_systems(Update, raw_commands.in_set(ConsoleSet::Commands))
.add_console_command::<MeshStateCommand, _>(check_mesh_state);
}
}
// 保持打开时不能操作人物
fn sync_flags(mut controller_flag: ResMut<ControllerFlag>, console_open: Res<ConsoleOpen>) {
controller_flag.flag = !console_open.open;
}
fn raw_commands(mut console_commands: EventReader<ConsoleCommandEntered>) {
for ConsoleCommandEntered { command_name, args } in console_commands.iter() {
println!(r#"Entered command "{command_name}" with args {:#?}"#, args);
}
}
#[derive(Parser, ConsoleCommand)]
#[command(
name = "mesh_state",
about = "check the state of the mesh on current clip_shperer"
)]
pub struct MeshStateCommand;
pub fn check_mesh_state(
mut mesh_state_command: ConsoleCommand<MeshStateCommand>,
clip_spheres: Res<ClipSpheres>,
mesh_manager: Res<MeshManager>,
chunk_map: Res<ChunkMap>,
) {
// something impl
}
makspll commented
Hi, does the command system actually run twice, or is it that ok
is printed twice ?
makspll commented
Also please try run with debug level logging and show the output
zzhgithub commented
zzhgithub commented
do you need my code . here is https://github.com/zzhgithub/just_join_v2
and I do not think there is some spiceal in my project.
zzhgithub commented
And I found sometimes i can not press KeyCode:H in console or just can not press any KeyCode. Why?
makspll commented
Hi @zzhgithub could you provide a minimal project which reproduces this, I do not see anything in the systems provided which would cause this behavior.