@@ -247,6 +247,12 @@ pub struct AssetPlugin {
247
247
/// Most use cases should leave this set to [`None`] and enable a specific watcher feature such as `file_watcher` to enable
248
248
/// watching for dev-scenarios.
249
249
pub watch_for_changes_override : Option < bool > ,
250
+ /// If set, will override the default "use asset processor" setting. By default "use asset
251
+ /// processor" will be `false` unless the `asset_processor` cargo feature is set.
252
+ ///
253
+ /// Most use cases should leave this set to [`None`] and enable the `asset_processor` cargo
254
+ /// feature.
255
+ pub use_asset_processor_override : Option < bool > ,
250
256
/// The [`AssetMode`] to use for this server.
251
257
pub mode : AssetMode ,
252
258
/// How/If asset meta files should be checked.
@@ -332,6 +338,7 @@ impl Default for AssetPlugin {
332
338
file_path : Self :: DEFAULT_UNPROCESSED_FILE_PATH . to_string ( ) ,
333
339
processed_file_path : Self :: DEFAULT_PROCESSED_FILE_PATH . to_string ( ) ,
334
340
watch_for_changes_override : None ,
341
+ use_asset_processor_override : None ,
335
342
meta_check : AssetMetaCheck :: default ( ) ,
336
343
unapproved_path_mode : UnapprovedPathMode :: default ( ) ,
337
344
}
@@ -360,10 +367,9 @@ impl Plugin for AssetPlugin {
360
367
embedded. register_source ( & mut sources) ;
361
368
}
362
369
{
363
- let mut watch = cfg ! ( feature = "watch" ) ;
364
- if let Some ( watch_override) = self . watch_for_changes_override {
365
- watch = watch_override;
366
- }
370
+ let watch = self
371
+ . watch_for_changes_override
372
+ . unwrap_or ( cfg ! ( feature = "watch" ) ) ;
367
373
match self . mode {
368
374
AssetMode :: Unprocessed => {
369
375
let mut builders = app. world_mut ( ) . resource_mut :: < AssetSourceBuilders > ( ) ;
@@ -378,8 +384,10 @@ impl Plugin for AssetPlugin {
378
384
) ) ;
379
385
}
380
386
AssetMode :: Processed => {
381
- #[ cfg( feature = "asset_processor" ) ]
382
- {
387
+ let use_asset_processor = self
388
+ . use_asset_processor_override
389
+ . unwrap_or ( cfg ! ( feature = "asset_processor" ) ) ;
390
+ if use_asset_processor {
383
391
let mut builders = app. world_mut ( ) . resource_mut :: < AssetSourceBuilders > ( ) ;
384
392
let processor = AssetProcessor :: new ( & mut builders) ;
385
393
let mut sources = builders. build_sources ( false , watch) ;
@@ -395,9 +403,7 @@ impl Plugin for AssetPlugin {
395
403
) )
396
404
. insert_resource ( processor)
397
405
. add_systems ( bevy_app:: Startup , AssetProcessor :: start) ;
398
- }
399
- #[ cfg( not( feature = "asset_processor" ) ) ]
400
- {
406
+ } else {
401
407
let mut builders = app. world_mut ( ) . resource_mut :: < AssetSourceBuilders > ( ) ;
402
408
let sources = builders. build_sources ( false , watch) ;
403
409
app. insert_resource ( AssetServer :: new_with_meta_check (
0 commit comments