Skip to content

Commit e42d386

Browse files
authored
set required-features for example light_textures & clustered_decals (#19913)
# Objective - Example `light_textures` exit if feature `pbr_light_textures` is not enabled. this is checked in code instead of using `required-features` - Same for `clustered_decals` and `par_clustered_decals` - Those examples are also using `eprintln` - Those examples are using `process:exit` to exit ## Solution - Use `required-features` - Use logs - Use `AppExit`
1 parent 607f9f2 commit e42d386

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4426,6 +4426,7 @@ wasm = true
44264426
name = "clustered_decals"
44274427
path = "examples/3d/clustered_decals.rs"
44284428
doc-scrape-examples = true
4429+
required-features = ["pbr_clustered_decals"]
44294430

44304431
[package.metadata.example.clustered_decals]
44314432
name = "Clustered Decals"
@@ -4437,6 +4438,7 @@ wasm = false
44374438
name = "light_textures"
44384439
path = "examples/3d/light_textures.rs"
44394440
doc-scrape-examples = true
4441+
required-features = ["pbr_light_textures"]
44404442

44414443
[package.metadata.example.light_textures]
44424444
name = "Light Textures"

examples/3d/clustered_decals.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use std::f32::consts::{FRAC_PI_3, PI};
44
use std::fmt::{self, Formatter};
5-
use std::process;
65

76
use bevy::{
87
color::palettes::css::{LIME, ORANGE_RED, SILVER},
@@ -163,16 +162,10 @@ fn setup(
163162
mut meshes: ResMut<Assets<Mesh>>,
164163
mut materials: ResMut<Assets<ExtendedMaterial<StandardMaterial, CustomDecalExtension>>>,
165164
) {
166-
// Error out if the clustered decals feature isn't enabled
167-
if !cfg!(feature = "pbr_clustered_decals") {
168-
eprintln!("Bevy was compiled without clustered decal support. Run with `--features=pbr_clustered_decals` to enable.");
169-
process::exit(1);
170-
}
171-
172165
// Error out if clustered decals aren't supported on the current platform.
173166
if !decal::clustered::clustered_decals_are_usable(&render_device, &render_adapter) {
174-
eprintln!("Clustered decals aren't usable on this platform.");
175-
process::exit(1);
167+
error!("Clustered decals aren't usable on this platform.");
168+
commands.send_event(AppExit::error());
176169
}
177170

178171
spawn_cube(&mut commands, &mut meshes, &mut materials);

examples/3d/light_textures.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use std::f32::consts::{FRAC_PI_2, FRAC_PI_3, FRAC_PI_4, PI};
44
use std::fmt::{self, Formatter};
5-
use std::process;
65

76
use bevy::{
87
color::palettes::css::{SILVER, YELLOW},
@@ -155,16 +154,10 @@ fn setup(
155154
mut meshes: ResMut<Assets<Mesh>>,
156155
mut materials: ResMut<Assets<StandardMaterial>>,
157156
) {
158-
// Error out if the light textures feature isn't enabled
159-
if !cfg!(feature = "pbr_light_textures") {
160-
eprintln!("Bevy was compiled without light texture support. Run with `--features=pbr_light_textures` to enable.");
161-
process::exit(1);
162-
}
163-
164157
// Error out if clustered decals (and so light textures) aren't supported on the current platform.
165158
if !decal::clustered::clustered_decals_are_usable(&render_device, &render_adapter) {
166-
eprintln!("Light textures aren't usable on this platform.");
167-
process::exit(1);
159+
error!("Light textures aren't usable on this platform.");
160+
commands.send_event(AppExit::error());
168161
}
169162

170163
spawn_cubes(&mut commands, &mut meshes, &mut materials);

0 commit comments

Comments
 (0)