Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RON formatting for Amethyst #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

conectado
Copy link

When trying to load an sprite sheet generated by the CLI using:

    let sheet_handle = {
        let loader = world.read_resource::<Loader>();
        let sheet_storage = world.read_resource::<AssetStorage<SpriteSheet>>();
        loader.load(
            "sprites/sprite_sheet.ron",
            SpriteSheetFormat(texture_handle),
            (),
            &sheet_storage,
        )
    };

I was getting and error due to the formatting of sprites/sprite_sheet.ron

[ERROR][amethyst_assets::progress] Error loading handle 6, Mesh, with name sprites/sprite_sheet..png: Asset was loaded but no handle to it was saved.
caused by: Asset was loaded but no handle to it was saved.
Error { inner: Inner { source: None, backtrace: None, error: UnusedHandle } }
[ERROR][amethyst_assets::progress] Note: to handle the error, use a `Progress` other than `()`
[ERROR][amethyst_assets::storage] "renderer::SpriteSheet": Asset "sprites/sprite_sheet.ron" (handle id: Handle { id: 0 }) could not be loaded: Failed to load asset with name "sprites/sprite_sheet.ron"
[ERROR][amethyst_assets::progress] Error loading handle 0, renderer::SpriteSheet, with name sprites/peakbeak.ron: Failed to load asset with name "sprites/sprite_sheet.ron"
caused by: Failed to load asset with name "sprites/sprite_sheet.ron"
Error { inner: Inner { source: Some(Error { inner: Inner { source: Some(Error { inner: Inner { source: None, backtrace: None, error: LoadSpritesheetError(Parser(ExpectedIdentifier, Position { col: 1, line: 1 })) } }), backtrace: None, error: Format("SPRITE_SHEET") } }), backtrace: None, error: Asset("sprites/peakbeak.ron") } }
caused by: Format "SPRITE_SHEET" could not load asset
Error { inner: Inner { source: Some(Error { inner: Inner { source: None, backtrace: None, error: LoadSpritesheetError(Parser(ExpectedIdentifier, Position { col: 1, line: 1 })) } }), backtrace: None, error: Format("SPRITE_SHEET") } }
caused by: Failed to parse SpriteSheet
Error { inner: Inner { source: None, backtrace: None, error: LoadSpritesheetError(Parser(ExpectedIdentifier, Position { col: 1, line: 1 })) } }
[ERROR][amethyst_assets::progress] Note: to handle the error, use a `Progress` other than `()`

When comparing the ron generated by the cli with the ron provided by Amethyst's examples I found out that the Sprite struct was wrapped with a List enum. So by doing the same with the output of AmethystFormat I managed to fix this problem.

Note: This PR includes a fix of #32 which I realize is fixed in #33 but was never merged and is currently outdated. If needed I can make a branch including only
436bec5 .

As explained in amethyst#32 relying on the OS to expand globs caused the CLI to fail in
Windows. By using glob it is currently working on Windwos.
When generating the `RON` Amethyst's asset loader wasn't able to read the
resouces. However, when adding this wrapper when generating the `RON` the struct
`SerializedSpriteSheet` is wrapped within a `List()` as per shown in Amethyst's
examples, making it work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant