improve error message for attempting to add systems using add_system_to_stage (#3287)
# Objective Fixes #3250 ## Solution Since this panic occurs in bevy_ecs, and StartupStage is part of bevy_app, we really only have access to the Debug string of the `stage_label` parameter. This led me to the hacky solution of comparing the debug output of the label the user provides with the known variants of StartupStage. An alternative would be to do this error handling further up in bevy_app, where we can access StartupStage's typeid, but I don't think it is worth having a panic in 2 places (_ecs, and _app).
This commit is contained in:
parent
f584e72953
commit
bb1538a139
@ -370,6 +370,10 @@ impl App {
|
|||||||
stage_label: impl StageLabel,
|
stage_label: impl StageLabel,
|
||||||
system: impl IntoSystemDescriptor<Params>,
|
system: impl IntoSystemDescriptor<Params>,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
|
use std::any::TypeId;
|
||||||
|
if stage_label.type_id() == TypeId::of::<StartupStage>() {
|
||||||
|
panic!("add systems to a startup stage using App::add_startup_system_to_stage");
|
||||||
|
}
|
||||||
self.schedule.add_system_to_stage(stage_label, system);
|
self.schedule.add_system_to_stage(stage_label, system);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@ -400,6 +404,10 @@ impl App {
|
|||||||
stage_label: impl StageLabel,
|
stage_label: impl StageLabel,
|
||||||
system_set: SystemSet,
|
system_set: SystemSet,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
|
use std::any::TypeId;
|
||||||
|
if stage_label.type_id() == TypeId::of::<StartupStage>() {
|
||||||
|
panic!("add system sets to a startup stage using App::add_startup_system_set_to_stage");
|
||||||
|
}
|
||||||
self.schedule
|
self.schedule
|
||||||
.add_system_set_to_stage(stage_label, system_set);
|
.add_system_set_to_stage(stage_label, system_set);
|
||||||
self
|
self
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user