-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assets as Entities #11266
Comments
For historical context, this was (mostly) originally proposed by @cart, and detailed a bit in #8624.
|
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.Entity
s (or a wrapper aroundEntity
).AssetLifetime
component. 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).AssetLifetime
ref count, it doesn't matter the type. Treating the same entity as a mesh and an image would just be 2 references.Assets
resource, 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.
The text was updated successfully, but these errors were encountered: