Skip to content

Commit 3c3d131

Browse files
committed
register_asset_source before plugin configuration
1 parent a4ab04e commit 3c3d131

2 files changed

Lines changed: 30 additions & 19 deletions

File tree

crates/processing_render/src/lib.rs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,21 @@ fn create_app(config: Config) -> App {
214214

215215
app.insert_resource(config.clone());
216216

217+
if let Some(asset_path) = config.get(ConfigKey::AssetRootPath) {
218+
app.register_asset_source(
219+
"assets_directory",
220+
AssetSourceBuilder::platform_default(asset_path, None),
221+
);
222+
}
223+
224+
if let Some(sketch_path) = config.get(ConfigKey::SketchRootPath) {
225+
println!("DEBUG SKETCH PATH = {sketch_path}");
226+
app.register_asset_source(
227+
"sketch_directory",
228+
AssetSourceBuilder::platform_default(sketch_path, None),
229+
);
230+
}
231+
217232
#[cfg(not(target_arch = "wasm32"))]
218233
let plugins = DefaultPlugins
219234
.build()
@@ -236,21 +251,11 @@ fn create_app(config: Config) -> App {
236251
..default()
237252
});
238253

239-
if let Some(asset_path) = config.get(ConfigKey::AssetRootPath) {
240-
app.register_asset_source(
241-
"assets_directory",
242-
AssetSourceBuilder::platform_default(asset_path, None),
243-
);
244-
}
245-
246254
app.add_plugins(plugins);
247-
if let Some(sketch_path) = config.get(ConfigKey::SketchRootPath) {
248-
println!("DEBUG SKETCH PATH = {sketch_path}");
249-
app.register_asset_source(
250-
"sketch_directory",
251-
AssetSourceBuilder::platform_default(sketch_path, None),
252-
)
253-
.add_plugins(sketch::LivecodePlugin);
255+
256+
if let Some(_) = config.get(ConfigKey::SketchRootPath) {
257+
info!("Adding plugin");
258+
app.add_plugins(sketch::LivecodePlugin);
254259
}
255260

256261
app.add_plugins((

crates/processing_render/src/sketch.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,23 @@ impl Plugin for LivecodePlugin {
1717
app.init_asset::<Sketch>()
1818
.init_asset_loader::<SketchLoader>()
1919
.add_systems(Startup, load_current_sketch);
20+
// .add_systems(Update, test_system);
21+
let render_app = app.sub_app_mut(bevy::render::RenderApp);
22+
render_app.add_systems(ExtractSchedule, test_system);
2023
}
2124
}
2225

26+
fn test_system() {
27+
info!("DEBUG: calling test_system");
28+
assert!(false);
29+
}
30+
2331
fn load_current_sketch(asset_server: Res<AssetServer>) {
32+
info!("DEBUG: calling load_current_sketch");
2433
let path = Path::new("rectangle.py");
2534
let source = AssetSourceId::from("sketch_directory");
26-
let _asset_path = AssetPath::from_path(path).with_source(source);
27-
28-
dbg!("OKOKOKOK {:?}", _asset_path);
29-
30-
let _h: Handle<Sketch> = asset_server.load(path);
35+
let asset_path = AssetPath::from_path(path).with_source(source);
36+
let _h: Handle<Sketch> = asset_server.load(asset_path);
3137
}
3238

3339
/// A sketch source file loaded as a Bevy asset.

0 commit comments

Comments
 (0)