From 317903f42a9df84aa18371b779c99b06b717e498 Mon Sep 17 00:00:00 2001 From: Niklas Eicker Date: Wed, 25 Oct 2023 21:37:03 +0200 Subject: [PATCH] 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` --- Cargo.toml | 2 +- examples/README.md | 2 +- .../{processing.rs => asset_processing.rs} | 29 ++++++++++++------- 3 files changed, 20 insertions(+), 13 deletions(-) rename examples/asset/processing/{processing.rs => asset_processing.rs} (90%) diff --git a/Cargo.toml b/Cargo.toml index 79e4b25adae2c..752968f1e181d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1102,7 +1102,7 @@ wasm = true [[example]] name = "asset_processing" -path = "examples/asset/processing/processing.rs" +path = "examples/asset/processing/asset_processing.rs" doc-scrape-examples = true required-features = ["file_watcher", "asset_processor"] diff --git a/examples/README.md b/examples/README.md index fde389848053d..d94a9a971f3d6 100644 --- a/examples/README.md +++ b/examples/README.md @@ -180,7 +180,7 @@ Example | Description Example | Description --- | --- [Asset Loading](../examples/asset/asset_loading.rs) | Demonstrates various methods to load assets -[Asset Processing](../examples/asset/processing/processing.rs) | Demonstrates how to process and load custom assets +[Asset Processing](../examples/asset/processing/asset_processing.rs) | Demonstrates how to process and load custom assets [Custom Asset](../examples/asset/custom_asset.rs) | Implements a custom asset loader [Custom Asset IO](../examples/asset/custom_asset_reader.rs) | Implements a custom AssetReader [Hot Reloading of Assets](../examples/asset/hot_asset_reloading.rs) | Demonstrates automatic reloading of assets when modified on disk diff --git a/examples/asset/processing/processing.rs b/examples/asset/processing/asset_processing.rs similarity index 90% rename from examples/asset/processing/processing.rs rename to examples/asset/processing/asset_processing.rs index eeba092372495..92c2884b627ab 100644 --- a/examples/asset/processing/processing.rs +++ b/examples/asset/processing/asset_processing.rs @@ -217,15 +217,22 @@ fn setup(mut commands: Commands, assets: Res) { }); } -fn print_text(handles: Res, texts: Res>) { - // This prints the current values of the assets - // Hot-reloading is supported, so try modifying the source assets (and their meta files)! - println!("Current Values:"); - println!(" a: {:?}", texts.get(&handles.a)); - println!(" b: {:?}", texts.get(&handles.b)); - println!(" c: {:?}", texts.get(&handles.c)); - println!(" d: {:?}", texts.get(&handles.d)); - println!(" e: {:?}", texts.get(&handles.e)); - println!("(You can modify source assets and their .meta files to hot-reload changes!)"); - println!(); +fn print_text( + handles: Res, + texts: Res>, + mut asset_events: EventReader>, +) { + if !asset_events.is_empty() { + // This prints the current values of the assets + // Hot-reloading is supported, so try modifying the source assets (and their meta files)! + println!("Current Values:"); + println!(" a: {:?}", texts.get(&handles.a)); + println!(" b: {:?}", texts.get(&handles.b)); + println!(" c: {:?}", texts.get(&handles.c)); + println!(" d: {:?}", texts.get(&handles.d)); + println!(" e: {:?}", texts.get(&handles.e)); + println!("(You can modify source assets and their .meta files to hot-reload changes!)"); + println!(); + asset_events.clear(); + } }