Skip to content

Typed alternative to load_folder #22222

@copygirl

Description

@copygirl

What problem does this solve or what need does it fill?

For my game I'm loading a single file with two different asset loaders, each producing a separate asset. One asset is a BlockDefinition which will contain all properties necessary to simulate the block, such as its collision shape and behavior. The other asset is a BlockVisuals which holds all that is necessary to display the block, such as mesh, texture and material. The latter would not be loaded on a headless server.

I want to be able to hot reload these assets including adding and removing them on the fly for ease of development or modding.

What solution would you like?

It would be nice to have a typed alternative to load_folder that allows me to specify what type of asset I want to load. Since this API will decide what type of asset to load a file as depending on the extension, I won't ever be able to load a single .ron file as two separate types of assets using it.

What alternative(s) have you considered?

  • Hardcode the asset paths instead.
  • Use a manifest file which mentions all the other files that need to load. Necessary on web anyway?
  • Split the file into two, with different extensions, so load_folder can handle them.
  • Register only a single asset loader, but a different one depending on whether on headless or client, which can then load BlockDefinition and BlockVisuals as sub-assets/dependencies from the single file with the right type explicitly, and use asset events to collect them into resources? Seems a bit over-engineered.

Additional context

Source code of the project available to browse here.

Related issues / pull requests

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-FeatureA new feature, making something new possibleS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions