Assets with embedded handles to other assets #9644
Labels
C-Feature
A new feature, making something new possible
S-Needs-Triage
This issue needs to be labelled
What problem does this solve or what need does it fill?
Complex assets such as scenes, UI layouts, and other high-level game data (quests, dialogues, skills, etc.) often contain embedded references to other, lower-level assets. I want to simplify how these dependent assets are loaded by allowing embedded asset references to be resolved by the asset loader for the containing asset.
For example, I'm working on a GUI asset format which contains a tree of nodes (widgets) that can reference other assets (stylesheets). A typical widget looks like this (in JSON):
The
styleset
property is a list of relative asset paths (resolving using my other PR #9473). When I decode the asset, the asset path is deserialized into a string; later, there's a system which walks the tree and callsserver.load()
on each asset path.However, it would be more efficient if I could create the asset handles in the decoder itself. This has several advantages:
add_asset_dependency
method.Unfortunately, an asset loader doesn't have access to the APIs needed to load another asset (at least, not that I can see). The only context available to an asset loader is
LoadContext
.LoadContext
does have aget_handle
method, but it takes a handle id, not a path. There doesn't seem to be any equivalent toserver.load()
.A description of why this particular feature should be added.
What solution would you like?
The easiest solution would be add a method to
LoadContext
that returns a handle given anAssetPath
.Additional Context
Note that the embedded references are handles, not the loaded data. In other words, the widget contains a handle to a stylesheet, not a stylesheet itself. This is by design - it facilitates hot reloading of stylesheets, so that when I edit the JSON file it doesn't need to completely re-create the UI, only the styles.
The text was updated successfully, but these errors were encountered: