Method ConvertToGhostPrefab
ConvertToGhostPrefab(EntityManager, Entity, Config, NativeParallelHashMap<Component, ComponentOverride>)
Converts an entity to a ghost prefab, and registers it with the collection.
This method will add the Prefab
and LinkedEntityGroup
components if they do not already exist.
It will also add all component required for a prefab to be used as a ghost, and register it with the GhostCollectionSystem
.
The blob asset (which is created as part of making it a ghost prefab) is owned (and will be freed by) the GhostCollectionSystem
.
Thus, the calling code should not free the blob asset.
The prefabs must be created exactly the same way on both the client and the server, and they must contain all components.
Use component overrides if you want to have some components server or client only.
Declaration
public static void ConvertToGhostPrefab(EntityManager entityManager, Entity prefab, GhostPrefabCreation.Config config, NativeParallelHashMap<GhostPrefabCreation.Component, GhostPrefabCreation.ComponentOverride> overrides = default)
Parameters
Type | Name | Description |
---|---|---|
Entity |
entityManager | Used to add components data on ghost children. |
Entity | prefab | Entity prefab to be converted. |
Ghost |
config | Configuration used to create a ghost prefab. |
Native |
overrides | Override types for specific components. |
Remarks
Note that - when using this in a System OnCreate
method - you must ensure your system is created after the DefaultVariantSystemGroup
,
as we must register serialization strategies before you access them.