Skip to content

Commit cda2db0

Browse files
committed
register_asset_source before plugin configuration
1 parent 9d0947e commit cda2db0

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

crates/processing_render/src/lib.rs

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

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

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

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

255260
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)