## Summary - register Bevy's image loader explicitly in the headless asset processor - use no GPU-compressed image formats because the processor has no render device - allow PNG processing tasks to complete so `ProcessorState` reaches `Finished` Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
37 lines
1.2 KiB
Rust
37 lines
1.2 KiB
Rust
use bevy::{
|
|
app::ScheduleRunnerPlugin,
|
|
asset::{AssetMode, AssetPlugin, processor::AssetProcessor, processor::ProcessorState},
|
|
gltf::GltfPlugin,
|
|
image::{CompressedImageFormats, ImageLoader, ImagePlugin},
|
|
prelude::*,
|
|
tasks::block_on,
|
|
text::TextPlugin,
|
|
};
|
|
use shinespark::AssetProcessingPlugin;
|
|
use std::{process::ExitCode, time::Duration};
|
|
|
|
fn main() -> ExitCode {
|
|
let mut app = App::new();
|
|
app.add_plugins(MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(Duration::from_millis(50))))
|
|
.add_plugins(AssetPlugin {
|
|
mode: AssetMode::Processed,
|
|
use_asset_processor_override: Some(true),
|
|
..default()
|
|
})
|
|
.add_plugins((ImagePlugin::default(), TextPlugin, GltfPlugin::default()))
|
|
.register_asset_loader(ImageLoader::new(CompressedImageFormats::NONE))
|
|
.add_plugins(AssetProcessingPlugin)
|
|
.add_systems(Update, finish_when_processed);
|
|
|
|
app.run();
|
|
ExitCode::SUCCESS
|
|
}
|
|
|
|
fn finish_when_processed(processor: Option<Res<AssetProcessor>>, mut exit: MessageWriter<AppExit>) {
|
|
if processor
|
|
.is_some_and(|processor| block_on(processor.get_state()) == ProcessorState::Finished)
|
|
{
|
|
exit.write(AppExit::Success);
|
|
}
|
|
}
|