Skip to content

Commit 191edec

Browse files
committed
register_asset_source before plugin configuration
1 parent ea33487 commit 191edec

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
@@ -216,6 +216,21 @@ fn create_app(config: Config) -> App {
216216

217217
app.insert_resource(config.clone());
218218

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

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

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