Struct GhostComponentSerializerCollectionData
Blittable. Ghost
Inherited Members
Namespace: Unity.NetCode
Assembly: Unity.NetCode.dll
Syntax
[BurstCompile]
public struct GhostComponentSerializerCollectionData : IComponentData, IQueryTypeParameter
Methods
AddInputComponent(ComponentType, ComponentType)
Used by code-generated systems and meant for internal use only. Adds a mapping from an IInputComponentData to the buffer it should use.
Declaration
public void AddInputComponent(ComponentType inputType, ComponentType bufferType)
Parameters
Type | Name | Description |
---|---|---|
Component |
inputType | Input type |
Component |
bufferType | Buffer type |
AddSerializationStrategy(ref ComponentTypeSerializationStrategy)
Used by code-generated systems to register SerializationStrategies. Internal use only.
Declaration
public void AddSerializationStrategy(ref ComponentTypeSerializationStrategy serializationStrategy)
Parameters
Type | Name | Description |
---|---|---|
Component |
serializationStrategy | Strategy to register. |
AddSerializer(State)
Used by code-generated systems and meant for internal use only.
Adds the generated ghost serializer to Ghost
Declaration
public void AddSerializer(GhostComponentSerializer.State state)
Parameters
Type | Name | Description |
---|---|---|
Ghost |
state | Serializer state. |
Dispose()
Release the allocated resources used to store the ghost serializer strategies and mappings.
Declaration
public void Dispose()
GetAllAvailableSerializationStrategiesForType(ComponentType, ulong, bool)
Finds all available variants for a given type, applying all variant rules at once.
Since multiple variants can be present for any given component there are some important use cases that need to be handled.
Note that, for Input
Note that the number of default variants returned may not be 1 (it could be more or less).
Declaration
[BurstCompile]
public NativeList<ComponentTypeSerializationStrategy> GetAllAvailableSerializationStrategiesForType(ComponentType componentType, ulong chosenVariantHash, bool isRoot)
Parameters
Type | Name | Description |
---|---|---|
Component |
componentType | Type to find the variant for. |
ulong | chosenVariantHash | If set, indicates that a variant has specifically been asked for (as an override). Zero implies find default. |
bool | isRoot | True if this component is on the root entity. |
Returns
Type | Description |
---|---|
Native |
A list of all available variants for this |
ThrowIfCollectionNotFinalized(in FixedString512Bytes)
We have no idea how many code-generated types are left to be registered, so instead,
we have a flag that is set when we know ALL of them have been created.
If the user queries this collection BEFORE all queries have been created, then they'll get silent errors where GhostFields default to DontSerializeVariant
.
Declaration
[Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")]
public void ThrowIfCollectionNotFinalized(in FixedString512Bytes context)
Parameters
Type | Name | Description |
---|---|---|
Fixed |
context | The context of this call, to aid in error reporting. |
Exceptions
Type | Condition |
---|---|
Invalid |
Throws if user-code queries too early. |
ThrowIfNoHash(ulong, FixedString512Bytes)
Validation that the SourceGenerators return valid hashes for "default serializers".
Declaration
[Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")]
public static void ThrowIfNoHash(ulong hash, FixedString512Bytes context)
Parameters
Type | Name | Description |
---|---|---|
ulong | hash | Hash to check. |
Fixed |
context | String context |
Exceptions
Type | Condition |
---|---|
Invalid |
If cannot add variant for |
ThrowIfNotInRegistrationPhase(in FixedString512Bytes)
We have no idea how many code-generated types are left to be registered, so instead,
we have a flag that is set when we know ALL of them have been created.
If the user queries this collection BEFORE all queries have been created, then they used to get silent errors where GhostFields default to DontSerializeVariant
.
This throw highlights that user-error.
Declaration
[Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")]
public void ThrowIfNotInRegistrationPhase(in FixedString512Bytes context)
Parameters
Type | Name | Description |
---|---|---|
Fixed |
context | The context of this call, to aid in error reporting. |
Exceptions
Type | Condition |
---|---|
Invalid |
Throws if user-code queries too early. |
TryGetBufferForInputComponent(ComponentType, out ComponentType)
Lookup a component type to use as a buffer for a given IInputComponentData.
Declaration
[Obsolete("TryGetBufferForInputComponent has been deprecated. In order to find the buffer associated with an IInputComponentData please just useIInputBuffer<T> where T is the IInputComponentData type you are looking for.", false)]
public bool TryGetBufferForInputComponent(ComponentType inputType, out ComponentType bufferType)
Parameters
Type | Name | Description |
---|---|---|
Component |
inputType | Component type |
Component |
bufferType | Buffer type |
Returns
Type | Description |
---|---|
bool | True if the component has an assosiated buffer to use, false if it does not. |
Validate()
Validate that all the serialization strategies have a valid Serializer
Declaration
[Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")]
public void Validate()