-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Assets as Entities #11266
Copy link
Copy link
Closed as duplicate of#23094
1 / 11 of 1 issue completedLabels
A-AssetsLoad files from disk to use for things like images, models, and soundsLoad files from disk to use for things like images, models, and soundsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-ComplexQuite challenging from either a design or technical perspective. Ask for help!Quite challenging from either a design or technical perspective. Ask for help!M-Release-NoteWork that should be called out in the blog due to impactWork that should be called out in the blog due to impactS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplishedX-ContentiousThere are nontrivial implications that should be thought throughThere are nontrivial implications that should be thought through
Metadata
Metadata
Assignees
Labels
A-AssetsLoad files from disk to use for things like images, models, and soundsLoad files from disk to use for things like images, models, and soundsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-ComplexQuite challenging from either a design or technical perspective. Ask for help!Quite challenging from either a design or technical perspective. Ask for help!M-Release-NoteWork that should be called out in the blog due to impactWork that should be called out in the blog due to impactS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplishedX-ContentiousThere are nontrivial implications that should be thought throughThere are nontrivial implications that should be thought through
What problem does this solve or what need does it fill?
The current asset system is stored in a single resource
Assets. This means we need a bespoke ID system for assets, events to report changes to assets, different patterns for adding/removing assets, etc.What solution would you like?
We can unify assets more tightly with the ECS by turning assets into entities.
Asset<MyAsset>component.Entitys (or a wrapper aroundEntity).AssetLifetimecomponent. Handles would refer to the same reference count and a system would check for assets with a ref count of 0 to despawn that entity.Possible issues
apply_deferred(although at least we can get the entity ID immediately so this is not too bad of an issue).AssetLifetimeref count, it doesn't matter the type. Treating the same entity as a mesh and an image would just be 2 references.Assetsresource, it's fairly hard to have unmanaged assets. Does this matter? For example, you can do weird things without the right systems with events (never clearing, for example). This would just be more of that.What alternative(s) have you considered?
Keep the system the same. The resource approach is very workable and is pretty nice to use. There are great guard rails (the types are very strong) and it's fairly hard to "break" it.
Additional context
This isn't originally my idea, I'm not sure whose it is though. I just remember hearing about this on Discord and wanted to document this.