33//! It can be created from raw pixel data, loaded from disk, resized, and read back to CPU memory.
44use std:: path:: PathBuf ;
55
6- #[ cfg( feature = "python" ) ]
7- use bevy:: asset:: { AssetPath , io:: AssetSourceId } ;
86use bevy:: {
97 asset:: {
10- LoadState , RenderAssetUsages , handle_internal_asset_events, io:: embedded:: GetAssetServer ,
8+ AssetPath , LoadState , RenderAssetUsages , handle_internal_asset_events,
9+ io:: { AssetSourceId , embedded:: GetAssetServer } ,
1110 } ,
1211 ecs:: { entity:: EntityHashMap , system:: RunSystemOnce } ,
1312 prelude:: * ,
@@ -25,6 +24,7 @@ use bevy::{
2524} ;
2625use half:: f16;
2726
27+ use crate :: config:: { Config , ConfigKey } ;
2828use crate :: error:: { ProcessingError , Result } ;
2929
3030pub struct ImagePlugin ;
@@ -140,10 +140,16 @@ pub fn from_handle(
140140}
141141
142142pub fn load ( In ( path) : In < PathBuf > , world : & mut World ) -> Result < Entity > {
143- #[ cfg( feature = "python" ) ]
144- let path = AssetPath :: from_path_buf ( path) . with_source ( AssetSourceId :: from ( "assets_directory" ) ) ;
143+ let config = world. resource_mut :: < Config > ( ) ;
144+ let path: AssetPath = match config. get ( ConfigKey :: AssetRootPath ) {
145+ Some ( _) => {
146+ AssetPath :: from_path_buf ( path) . with_source ( AssetSourceId :: from ( "assets_directory" ) )
147+ }
148+ None => AssetPath :: from_path_buf ( path) ,
149+ } ;
145150
146151 let handle: Handle < bevy:: image:: Image > = world. get_asset_server ( ) . load ( path) ;
152+
147153 while let LoadState :: Loading = world. get_asset_server ( ) . load_state ( & handle) {
148154 world. run_system_once ( handle_internal_asset_events) . unwrap ( ) ;
149155 }
0 commit comments