Allow missing assets
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
I'd like a way to suppress the error when an asset file is not found. Two example use cases:
* When the asset subfolder is being used as a cache, and a cache miss is not an error.
* For modding, when the existence of a particular asset is a signal which enables a feature.
## What solution would you like?
This could be a feature of the AssetLoader trait. One idea is to have a new method called `load_default()` which is called when the asset is not found - the default implementation would be to return an error. Users could then override this method to return a default version of the asset. Note that we have to return *something*, as the API for loading assets doesn't allow a handle to point to nothing. It would be up to the user to include a flag or property within the default asset to indicate that this is a missing asset.
Another approach would be to have a special error code that indicates that the asset is not there, but the normal error message should be suppressed.
## What alternative(s) have you considered?
One alternative is to scan the folder and check all the asset names, but this is expensive, especially if you are writing assets during play.
Contributor guide
Research direction
Start by reading the AssetLoader trait and the asset-loading API to understand how missing files currently become errors and why a handle must always refer to an asset. Compare the proposed load_default() behavior with the special-error approach and determine which API semantics are acceptable. Done requires an agreed design for missing assets, a defined fallback or error behavior, and coverage for cache-miss and modding use cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100