bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.11k stars 3.45k forks source link

Bevy Asset V2 Tracking Issue #9714

Open cart opened 1 year ago

cart commented 1 year ago

Bevy Asset V2 PR is merged, but there is still plenty of followup work to do! This issue exists to enumerate and track all of this work, although I suspect once the dust settles and we resolve the important stuff, we'll eventually want to close this rather than keep it alive indefinitely.

Immediate Short Term Followups And Tweaks

These are relatively scoped tweaks and fixes that should be resolved in the short term, prior to kicking off other larger efforts.

Larger Next Steps / Things to Investigate

These are larger changes and features that we will ultimately want.

hymm commented 11 months ago

I think we also need a fallback feature for asset sources. i.e. you tried to load from the file system, but that didn't exist so you now go to a LFS server to get the asset.

Maybe this can just be an asset source type that can use other asset sources.

cart commented 11 months ago

Maybe this can just be an asset source type that can use other asset sources.

@hymm yeah I think this would be best expressed as a FallbackAssetReader / Writer / etc that can be configured with an ordered list of sources to try.

lizelive commented 10 months ago

trying to understand. for asset v2, would settings field allow passing assets/dependencies? an example is loading midi file and setting sound font as a dependency?

cart commented 10 months ago

trying to understand. for asset v2, would settings field allow passing assets/dependencies? an example is loading midi file and setting sound font as a dependency?

Yup this is possible. You could pass in an AssetPath string via the settings and then use that to load a dependency.

torsteingrindvik commented 10 months ago

I recently (on Bevy main) tried doing something to this effect:

fn system(asset_server: Res<AssetServer>) {
    let handle1: Handle<Foo> = asset_server.load("cool1.ron");
    let handle2: Handle<Bar> = asset_server.load("cool2.ron");
}

and I naively registered multiple asset loaders for the ron extension- one for output Foo and the other for Bar. At runtime it seems only the last loader was applied, so then I get an error when Foo is being deserialized (since it tries to make it a Bar).

(EDIT: So in my head without knowledge of bevy_asset I was hoping somehow the asset system would choose a loader based on my stated output handle type Handle<T> instead of the file extension).

Is this use-case somehow covered by v2? The closest issue I found was this https://github.com/bevyengine/bevy/issues/367

My workaround workflow is this:

Which feels less elegant than I'd hoped.

I think another workaround is to change files around to new extensions, e.g.

and register separate loaders for them.

But in my case the .ron files belong to a larger Rust project where Bevy doesn't "own" these assets and changing their names would implicate the larger project, so I'm looking for other workflows.

duaneking commented 10 months ago

The v2 update breaks all prior code, and that's why I personally, in this moment, hate this poorly documented and poor quality change.

All the bevy code I have seen on github is now utterly broken by this; Worse, The update path is not clear as the "initial migration guide" noted above isn't even linked to, so how are people going to find it?

Please understand that you are creating pain and suffering for others with these poorly documented changes.

nicopap commented 10 months ago

Here is a list of recently open issue on assets:

Bugs

Missing features

Error reporting

BeastLe9enD commented 5 months ago

Add true Ignore AssetAction that does not copy the asset to the imported_assets folder

I would make a PR for this if its ok, just for clarification: Do we want to change the behavior of Ignore that the files are not copied anymore, or do we want a new AssetAction?

cart commented 5 months ago

Yeah that would be welcome! I think we might want two AssetActions (names TBD):

  1. Skip: skips the asset during processing, attempting to load directly would fail (no copy to processed folder)
  2. Ignore: copies the asset to the processed folder, but without a configured loader or processor. Trying to load would fail (the current behavior)

However I think implementing Skip is the most important thing. I'm not yet sure we actually need Ignore.

BeastLe9enD commented 5 months ago

@cart Okay fine, I did a PR which actually does no copy when asset action is Ignore a few days ago (#12605). If we still want Ignore, I can make a second PR that introduces the behavior you described :)

brandon-reinhart commented 3 months ago

Starting work on folder meta and per-type defaults here... #13785

brandon-reinhart commented 3 months ago

I think comfortable N to one processing could be done using meta defaults and @BeastLe9enD 's ignore feature. You could ignore the input assets using a meta_default file and have the processing rule in another asset type. So, for a texture atlas, you'd have the pngs be ignored by png.meta_default and a texture_atlas.meta_default would describe how to process the texture atlas. (Or my_items.texture_atlas.meta if you wanted to customize a particular atlas... etc...)

(In my testing of this idea, a RawTextureAtlasLoader reads the images and TextureAtlasTransformer turns it into an atlas. With some other minor changes, the resulting stitched image and TextureAtlasLayout are written by a TextureAtlasSaver.)

To finish that entire chain of thought, we would need: