Make SystemId
s easier to create and manage using SystemHandle
s
#10426
Labels
A-ECS
Entities, components, systems, and events
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
What problem does this solve or what need does it fill?
Currently it isn't simple to create and manage
SystemId
s. For them to be widely used, there needs to be a simple way to work with them.Reasons they are hard to create:
&mut World
is required to create them.register_system
inspawn
arguments because both take&mut World
.Reasons they are hard to manage:
Resource
s orComponent
sWhat solution would you like?
Manage
SystemId
lifetimes using a new type. I proposeSystemHandle
. It would act like an assetHandle
where it keeps track of references and removes the system when it is no longer being used.Also an easy way to create
SystemHandle
s. I would suggest a new type that acts like one ofAssetServer
,Assets
, orCommands
.In the future
SystemHandle
could be used by scenes to reference systems. Maybe theTypeId
of the system could be used in aSystemPath
. This would require the systems to be registered ahead of time. This can be done inPlugin
s like so:app.world.register_system(system)
.What alternative(s) have you considered?
We could add a methods to
Commands
andChildBuilder
for creating handles instead of creating a new type to createSystemHandles
. This has the drawback that you can't inline creating aSystemHandle
in the arguments ofspawn
.Is it possible to use the asset system for this and just use
Handle<SystemId>
? Would this be a good idea even if it were possible?Additional context
I quickly wrote a proof of concept plugin:
Plugin
Here is an example of how I use it to spawn a button:
Example usage
The text was updated successfully, but these errors were encountered: