File tree 2 files changed +24
-4
lines changed 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ impl Plugin for WireframePlugin {
41
41
. add_systems (
42
42
Update ,
43
43
(
44
- global_color_changed. run_if ( resource_changed :: < WireframeConfig > ) ,
44
+ global_color_changed,
45
45
wireframe_color_changed,
46
46
// Run `apply_global_wireframe_material` after `apply_wireframe_material` so that the global
47
47
// wireframe setting is applied to a mesh on the same frame its wireframe marker component is removed.
@@ -115,12 +115,22 @@ fn setup_global_wireframe_material(
115
115
116
116
/// Updates the wireframe material of all entities without a [`WireframeColor`] or without a [`Wireframe`] component
117
117
fn global_color_changed (
118
+ mut desynced : Local < bool > ,
118
119
config : Res < WireframeConfig > ,
119
120
mut materials : ResMut < Assets < WireframeMaterial > > ,
120
121
global_material : Res < GlobalWireframeMaterial > ,
121
122
) {
122
- if let Some ( global_material) = materials. get_mut ( & global_material. handle ) {
123
+ if config. is_changed ( ) {
124
+ * desynced = true ;
125
+ }
126
+ if !* desynced {
127
+ // There's been no change, so bail out early.
128
+ return ;
129
+ }
130
+ if let Ok ( global_material) = materials. get_mut ( & global_material. handle ) {
123
131
global_material. color = config. default_color . into ( ) ;
132
+ // Clear the desynced flag to mark that we don't need to rerun this system.
133
+ * desynced = false ;
124
134
}
125
135
}
126
136
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ impl Plugin for Wireframe2dPlugin {
41
41
. add_systems (
42
42
Update ,
43
43
(
44
- global_color_changed. run_if ( resource_changed :: < Wireframe2dConfig > ) ,
44
+ global_color_changed,
45
45
wireframe_color_changed,
46
46
// Run `apply_global_wireframe_material` after `apply_wireframe_material` so that the global
47
47
// wireframe setting is applied to a mesh on the same frame its wireframe marker component is removed.
@@ -111,12 +111,22 @@ fn setup_global_wireframe_material(
111
111
112
112
/// Updates the wireframe material of all entities without a [`Wireframe2dColor`] or without a [`Wireframe2d`] component
113
113
fn global_color_changed (
114
+ mut desynced : Local < bool > ,
114
115
config : Res < Wireframe2dConfig > ,
115
116
mut materials : ResMut < Assets < Wireframe2dMaterial > > ,
116
117
global_material : Res < GlobalWireframe2dMaterial > ,
117
118
) {
118
- if let Some ( global_material) = materials. get_mut ( & global_material. handle ) {
119
+ if config. is_changed ( ) {
120
+ * desynced = true ;
121
+ }
122
+ if !* desynced {
123
+ // There's been no change, so bail out early.
124
+ return ;
125
+ }
126
+ if let Ok ( global_material) = materials. get_mut ( & global_material. handle ) {
119
127
global_material. color = config. default_color . into ( ) ;
128
+ // Clear the desynced flag to mark that we don't need to rerun this system.
129
+ * desynced = false ;
120
130
}
121
131
}
122
132
You can’t perform that action at this time.
0 commit comments