File tree 2 files changed +6
-6
lines changed
2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ pub fn swap_3d_tex_from_idx(
42
42
user_textures : Res < TexHandleQueue > ,
43
43
) {
44
44
// Iterate over all `YourShader` assets
45
- for ( _, shad_mat) in shader_mat3d. iter_mut ( ) {
45
+ if let Some ( ( _, shad_mat) ) = shader_mat3d. iter_mut ( ) . next ( ) {
46
46
key_evr. read ( ) . for_each ( |ev| {
47
47
if let ButtonState :: Pressed = ev. state {
48
48
match ev. key_code {
@@ -60,7 +60,7 @@ pub fn swap_3d_tex_from_idx(
60
60
}
61
61
}
62
62
} ) ;
63
- break ; // Exit after processing the first shader.
63
+ return ;
64
64
}
65
65
}
66
66
@@ -93,7 +93,7 @@ pub fn swap_2d_tex_from_idx(
93
93
mut shader_mat2d : ResMut < Assets < YourShader2D > > ,
94
94
user_textures : Res < TexHandleQueue > ,
95
95
) {
96
- for ( _, shad_mat) in shader_mat2d. iter_mut ( ) {
96
+ if let Some ( ( _, shad_mat) ) = shader_mat2d. iter_mut ( ) . next ( ) {
97
97
key_evr. read ( ) . for_each ( |ev| {
98
98
if let ButtonState :: Pressed = ev. state {
99
99
match ev. key_code {
@@ -111,6 +111,6 @@ pub fn swap_2d_tex_from_idx(
111
111
}
112
112
}
113
113
} ) ;
114
- return ; // Exit after processing the first shader.
114
+ return ;
115
115
}
116
116
}
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ pub fn add_and_set_dropped_file(
98
98
tex_handles. insert ( new_idx, texture) ;
99
99
100
100
// Try to set the texture for the first found `YourShader2D`
101
- for ( _, shad_mat) in shader_mat_2d. iter_mut ( ) {
101
+ if let Some ( ( _, shad_mat) ) = shader_mat_2d. iter_mut ( ) . next ( ) {
102
102
YourShader2D :: set_current_tex ( shad_mat, new_idx, & tex_handles) ;
103
103
104
104
#[ cfg( debug_assertions) ]
@@ -107,7 +107,7 @@ pub fn add_and_set_dropped_file(
107
107
}
108
108
109
109
// If no `YourShader2D` was found, try setting it for the first `YourShader`
110
- for ( _, shad_mat) in shader_mat_3d. iter_mut ( ) {
110
+ if let Some ( ( _, shad_mat) ) = shader_mat_3d. iter_mut ( ) . next ( ) {
111
111
YourShader :: set_current_tex ( shad_mat, new_idx, & tex_handles) ;
112
112
113
113
#[ cfg( debug_assertions) ]
You can’t perform that action at this time.
0 commit comments