Skip to content

Commit 317903f

Browse files
authored
Reduce noise in asset processing example (#10262)
# Objective - Reduce noise to allow users to see previous asset changes and other logs like from asset reloading - The example file is named differently than the example ## Solution - Only print the asset content if there are asset events - Rename the example file to `asset_processing`
1 parent 442a316 commit 317903f

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ wasm = true
11021102

11031103
[[example]]
11041104
name = "asset_processing"
1105-
path = "examples/asset/processing/processing.rs"
1105+
path = "examples/asset/processing/asset_processing.rs"
11061106
doc-scrape-examples = true
11071107
required-features = ["file_watcher", "asset_processor"]
11081108

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Example | Description
180180
Example | Description
181181
--- | ---
182182
[Asset Loading](../examples/asset/asset_loading.rs) | Demonstrates various methods to load assets
183-
[Asset Processing](../examples/asset/processing/processing.rs) | Demonstrates how to process and load custom assets
183+
[Asset Processing](../examples/asset/processing/asset_processing.rs) | Demonstrates how to process and load custom assets
184184
[Custom Asset](../examples/asset/custom_asset.rs) | Implements a custom asset loader
185185
[Custom Asset IO](../examples/asset/custom_asset_reader.rs) | Implements a custom AssetReader
186186
[Hot Reloading of Assets](../examples/asset/hot_asset_reloading.rs) | Demonstrates automatic reloading of assets when modified on disk

examples/asset/processing/processing.rs renamed to examples/asset/processing/asset_processing.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,22 @@ fn setup(mut commands: Commands, assets: Res<AssetServer>) {
217217
});
218218
}
219219

220-
fn print_text(handles: Res<TextAssets>, texts: Res<Assets<Text>>) {
221-
// This prints the current values of the assets
222-
// Hot-reloading is supported, so try modifying the source assets (and their meta files)!
223-
println!("Current Values:");
224-
println!(" a: {:?}", texts.get(&handles.a));
225-
println!(" b: {:?}", texts.get(&handles.b));
226-
println!(" c: {:?}", texts.get(&handles.c));
227-
println!(" d: {:?}", texts.get(&handles.d));
228-
println!(" e: {:?}", texts.get(&handles.e));
229-
println!("(You can modify source assets and their .meta files to hot-reload changes!)");
230-
println!();
220+
fn print_text(
221+
handles: Res<TextAssets>,
222+
texts: Res<Assets<Text>>,
223+
mut asset_events: EventReader<AssetEvent<Text>>,
224+
) {
225+
if !asset_events.is_empty() {
226+
// This prints the current values of the assets
227+
// Hot-reloading is supported, so try modifying the source assets (and their meta files)!
228+
println!("Current Values:");
229+
println!(" a: {:?}", texts.get(&handles.a));
230+
println!(" b: {:?}", texts.get(&handles.b));
231+
println!(" c: {:?}", texts.get(&handles.c));
232+
println!(" d: {:?}", texts.get(&handles.d));
233+
println!(" e: {:?}", texts.get(&handles.e));
234+
println!("(You can modify source assets and their .meta files to hot-reload changes!)");
235+
println!();
236+
asset_events.clear();
237+
}
231238
}

0 commit comments

Comments
 (0)