Giter Club home page Giter Club logo

bevy_embedded_assets's People

Contributors

jf908 avatar mockersf avatar rparrett avatar smellypengu avatar thisjaiden avatar zachbateman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bevy_embedded_assets's Issues

Assets in subdirectories don't load on Wasm unless you use the proper slash type

Issue

If some conditions are met:

  • You are on Windows,
  • Some assets are placed in a subdirectory of the assets folder,
  • You use forward slashes when specifying the path of the asset to load,

then the aforementioned assets won't load.

How to Replicate

  • Be on Windows
  • Place an asset in a subdirectory of the assets dir (e.g., assets/foo/bar.png)
  • Load the asset (asset_server.load("foo/bar.png"))
  • Observe a loading error (path not found)

Expected Result

Assets being actually loaded.

Notes

Apparently Paths do not convert forward slashes into backward ones in Wasm builds, which is the cause of the problem.

I think using backslashes won't fix the problem: it will break on Linux/MacOS instead (I haven't tested it, but I assume backslashes won't be converted into forward slashes on these platforms).

This is inconvenient since it hinders cross-platform development.

Error while compiling a workspace

Hello,

I have a workspace with the following structure :

client
| assets
server
| assets

But when I run/build one crate or the other, I have this error :

warning: Could not find the asset folder from the Cargo build directory
warning: Could not find asset folder, please specify its path with $BEVY_ASSET_PATH
error: failed to run custom build command for bevy_embedded_assets v0.4.0

I managed to fix the issue by copying/pasting my asset folders at the root level, but duplicating assets isn't an ideal solution.

This issue appeared right after I split my project into multiple crates.

If you need more information, I would be glad to help!

Plugin implementation doesn't exists

1  error[E0277]: the trait bound `bevy_embedded_assets::EmbeddedAssetPlugin: bevy::prelude::Plugin` is not satisfied
    --> src/main.rs:11:60
     |
 11  |                 .add_before::<bevy::asset::AssetPlugin, _>(EmbeddedAssetPlugin),
     |                  ----------                                ^^^^^^^^^^^^^^^^^^^ the trait `bevy::prelude::Plugin` is not implemented for `bevy_embedded_assets::EmbeddedAssetPlugin`
     |                  |
     |                  required by a bound introduced by this call
     |
     = help: the following other types implement trait `bevy::prelude::Plugin`:
               bevy::a11y::AccessibilityPlugin
               bevy::app::ScheduleRunnerPlugin
               bevy::asset::diagnostic::AssetCountDiagnosticsPlugin<T>
               bevy::audio::AudioPlugin
               bevy::core_pipeline::CorePipelinePlugin
               bevy::core_pipeline::blit::BlitPlugin
               bevy::core_pipeline::bloom::BloomPlugin
               bevy::core_pipeline::core_2d::Core2dPlugin
             and 62 others
 note: required by a bound in `bevy::app::PluginGroupBuilder::add_before`
    --> /home/freyja-moth/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_app-0.10.1/src/plugin_group.rs:124:42
     |
 124 |     pub fn add_before<Target: Plugin, T: Plugin>(mut self, plugin: T) -> Self {
     |                                          ^^^^^^ required by this bound in `PluginGroupBuilder::add_before`

 For more information about this error, try `rustc --explain E0277`.
 error: could not compile `game` (bin "game" test) due to previous error

You know I really have no idea how I got into this situation.

This is my current code, which is almost identical to the example given

pub mod prelude;
pub mod state;

use prelude::*;

fn main() {
    App::new()
        .add_plugins(
            DefaultPlugins
                .build()
                .add_before::<bevy::asset::AssetPlugin, _>(EmbeddedAssetPlugin),
        )
        .add_plugins(GamePlugins)
        .run()
}

Backslash paths on Windows are not escaped

Issue

Paths on Windows that use backslashes are not properly escaped and result in invalid codegen.

Replication

  1. Be on Windows in a bevy project folder
  2. Create a .cargo/config.toml in project folder with (expects assets to also be in project root)
    [env]
    BEVY_ASSET_PATH = { relative = true, value = "assets" }
  3. Observe invalid output target/debug/build/bevy_embedded_assets_HASH/out/include_all_assets.rs
    /// Generated function that will add all assets to the [`EmbeddedAssetIo`].
    #[allow(unused_variables)] pub fn include_all_assets(embedded: &mut EmbeddedAssetIo){
    embedded.add_asset(std::path::Path::new("face.blend"), include_bytes!("path\prefix\assets\myAsset.ext"));

Expected outcome

Paths with backslashes should have the backslashes escaped.

Example expected output:

/// Generated function that will add all assets to the [`EmbeddedAssetIo`].
#[allow(unused_variables)] pub fn include_all_assets(embedded: &mut EmbeddedAssetIo){
embedded.add_asset(std::path::Path::new("face.blend"), include_bytes!("path\\prefix\\assets\\myAsset.ext"));

Support Bevy 0.12?

It looks like Bevy 0.12 includes some support for embedded assets: https://bevyengine.org/news/bevy-0-12/#embedded-assets

That said, this crate has been working great for me, and I'm having trouble trying to get the Bevy 0.12 embedded assets working as a replacement. Should/can this crate be updated to support Bevy 0.12, or should we switch to using Bevy itself for embedded assets?

Provide a default value for the BEVY_ASSET_PATH

I'm trying to setup a build process using cross-rs. Unfortunately, I have to manually specificy the BEVY_ASSET_PATH before the command. Also unfortunately, it's ran in a docker container so an absolute path is unhelpful. If I pass in BEVY_ASSET_PATH=./assets then this mod tries to load assets from its example dir (which doesn't exist). You can reproduce this now by running BEVY_ASSET_PATH=./assets cargo run and seeing the error outputs from bevy_embedded_assets.

I propose either 2 solutions.

1 - make the env var of BEVY_ASSET_PATH relative to the cargo workspace root

2 - default the value of BEVY_ASSET_PATH to be the root of the project with /assets (as that's the bevy default)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.