Skip to content
Snippets Groups Projects
Commit 2d5e4e8b authored by John Mitchell's avatar John Mitchell
Browse files

Fixed issue where wasm fails to build.

parent 41c63963
No related branches found
No related tags found
No related merge requests found
use bevy::{ use bevy::{
asset::{AssetLoader, FileAssetIo, LoadContext, LoadedAsset}, asset::{AssetLoader, LoadContext, LoadedAsset},
render::render_resource::{Extent3d, TextureFormat}, render::render_resource::{Extent3d, TextureFormat},
utils::{BoxedFuture, HashMap}, utils::{BoxedFuture, HashMap},
}; };
#[cfg(not(target_family = "wasm"))]
use bevy::asset::FileAssetIo;
use image::{EncodableLayout, RgbaImage}; use image::{EncodableLayout, RgbaImage};
use nanoserde::DeJson; use nanoserde::DeJson;
...@@ -26,10 +30,12 @@ impl AssetLoader for TTFLoader { ...@@ -26,10 +30,12 @@ impl AssetLoader for TTFLoader {
load_context: &'a mut LoadContext, load_context: &'a mut LoadContext,
) -> BoxedFuture<'a, Result<(), anyhow::Error>> { ) -> BoxedFuture<'a, Result<(), anyhow::Error>> {
Box::pin(async move { Box::pin(async move {
#[cfg(not(target_family = "wasm"))]
let asset_io = load_context let asset_io = load_context
.asset_io() .asset_io()
.downcast_ref::<FileAssetIo>() .downcast_ref::<FileAssetIo>()
.unwrap(); .unwrap();
let kttf: KTTF = let kttf: KTTF =
nanoserde::DeJson::deserialize_json(std::str::from_utf8(bytes).unwrap()).unwrap(); nanoserde::DeJson::deserialize_json(std::str::from_utf8(bytes).unwrap()).unwrap();
...@@ -179,6 +185,7 @@ impl AssetLoader for TTFLoader { ...@@ -179,6 +185,7 @@ impl AssetLoader for TTFLoader {
} }
let image_bytes = if cache_image.is_err() { let image_bytes = if cache_image.is_err() {
#[cfg(not(target_family = "wasm"))]
image_builder image_builder
.save(asset_io.root_path().join(cache_path)) .save(asset_io.root_path().join(cache_path))
.unwrap(); .unwrap();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment