diff --git a/Cargo.toml b/Cargo.toml index 3d77e10..3651737 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ all-features = true [features] default = [] -unstable-load-from-file = ["serde", "serde_yaml", "anyhow", "bevy_utils"] +unstable-load-from-file = ["serde", "serde_yaml", "ron", "anyhow", "bevy_utils"] [dependencies] bevy_core = { version = "0.7.0", default-features = false } diff --git a/assets/coin.animation.ron b/assets/coin.animation.ron new file mode 100644 index 0000000..198c3b4 --- /dev/null +++ b/assets/coin.animation.ron @@ -0,0 +1,5 @@ +( + mode: Repeat, + frame_duration: Some(100), + frames: [0, 1, 2, 3, 4], +) diff --git a/src/animation/load.rs b/src/animation/load.rs index b9ef60e..c2cde75 100644 --- a/src/animation/load.rs +++ b/src/animation/load.rs @@ -12,13 +12,17 @@ impl AssetLoader for SpriteSheetAnimationLoader { load_context: &'a mut LoadContext<'_>, ) -> BoxedFuture<'a, Result<(), anyhow::Error>> { Box::pin(async move { - let custom_asset = SpriteSheetAnimation::from_yaml_bytes(bytes)?; + let custom_asset = match load_context.path().extension().unwrap().to_str().unwrap() { + "yaml" | "yml" => SpriteSheetAnimation::from_yaml_bytes(bytes)?, + "ron" => SpriteSheetAnimation::from_ron_bytes(bytes)?, + _ => unreachable!(), + }; load_context.set_default_asset(LoadedAsset::new(custom_asset)); Ok(()) }) } fn extensions(&self) -> &[&str] { - &["animation.yml", "animation.yaml"] + &["animation.yml", "animation.yaml", "animation.ron"] } }