Closed jeffcampbellmakesgames closed 4 years ago
Thinking about this more while working on a side project, I'd also like to be able to scaffold systems grouped into a Feature
by way of a code attribute and code generation. This would be allow me to easily define several Feature
, nest them as appropriate under a Systems
in a minimal bootstrap class, and then as those Feature
grew I would no longer need to manually update the bootstrap class unless a new top-level Feature
is added
Couple of reference links for better polymorphism support for POCO types in Unity 2019.3 and later
[SerializeReference]
does seem to work well for polymorphic types where the common implementing type is IComponent
. To easily enable inspector support for blueprints in the editor, I'm likely going to be refactoring some of the inspector/drawer code into the core EntitasRedux.Editor
assembly so that multiple modules (visual debugging, blueprints) can both have access to that functionality without directly relying on each other. Since this is all editor code, this should not have any impact on runtime functionality.
I may want to limit the amount of inspectable/addable types on a blueprint to only those that Unity can serialize as there is inspector support for some types that aren't supported for native serialization by the Unity Editor (looking at you Dictionary<T, TV>
).
Making some progress on this; each context now gets their own Monobehaviour
-derived blueprint class which using a single inspector can show a list of IComponent
and I have some WIP code enabling popup selection of serializable components specific to that context for adding to that list.
Couple of notes for later:
[Serializable]
to illustrate this feature.ScriptableObject
as this would enable a developer to store blueprints more like asset configs that could be applied to one or more newly created entities in code versus in a scene on a single object or on a prefab. This would only be possible if it were possible to use blueprint's more like settings that could be applied to an entity via deep copying or copying member values rather than the instance data for an entity.
Blueprint
attribute on a component based on a code-gen setting.Making progress refactoring the previously existing component/type drawer functionality used for visual debugging so that a developer can design what components should exist for an entity or entities based on a blueprint.
Refactored the inspector logic for the blueprint Monobehaviour
so it could easily be reused and setup code gen to support both a Monobehaviour
-based blueprint as well as a ScriptableObject
-based blueprint.
BlueprintBehaviour
=> Derives from MonoBehaviour
Blueprint
=> Derives from ScriptableObject
Now that there is a solid base for adding/removing components on a blueprint, taking a look at what would be needed to apply those to a component. The goal here is not that these components are used directly, but instead act as the blueprint for components to be set/replaced onto an entity.
ComponentLookup
now has a dictionary lookup of component type to index to make it easier to get the appropriate index for a given component in an List<IComponent>
.
Entity
also has a new method CopyFromXTo
that enables copying an existing component to another entity as a new instances of a component. This has the same API flow/events as replacing a component.
Documentation for this feature has been created on the wiki here.
This has been merged to develop.
Is your feature request related to a problem? Please describe.
Blueprints are a feature intended to make it easier to configure Entities in the Unity Editor much like you would a prefab, but are currently too problematic for a variety of reasons to include with the main library of EntitasRedux. There is value in being able to configure Entities in the Unity Editor directly without code or with a minimum of configuration/decoration.
Describe the solution you'd like
Ideally, for a user they would be able to add some sort of component for an Entity of a given context to a GameObject and add/remove/modify components at will. When playing, using this component on an object should automatically create the Entity and add the user-configured components.
Implementation Tasks
Blueprint Entity