Struct ComponentTypeSerializationStrategy
For internal use only. Stores individual "serialization strategies" (and meta-data) for all netcode-informed components, as well as all variants of these components (GhostComponentVariationAttribute). Thus, maps to the code-generated GhostComponentSerializer ("Default Serializers") as well as all user-created Variants (GhostComponentVariationAttribute). This type also stores instances of the DontSerializeVariant, ClientOnlyVariant, and ServerOnlyVariant.
Note: Serializers are considered "optional". It is perfectly valid for a types "serialization strategy" to be: "Do nothing". An example of this is a component for which a variant has been declared (using the GhostComponentVariationAttribute) but for which serialization is not generated, i.e: the GhostInstance attribute is specified in the base component declaration, but not in a variant. We call these "Empty Variants".
Inherited Members
Namespace: Unity.NetCode
Syntax
public struct ComponentTypeSerializationStrategy : IComparable<ComponentTypeSerializationStrategy>
Remarks
This type was renamed from "VariantType" for 1.0.
Fields
Component
Component that this Variant is associated with.
Declaration
public ComponentType Component
Field Value
Type | Description |
---|---|
ComponentType |
DefaultRule
Declaration
public ComponentTypeSerializationStrategy.DefaultType DefaultRule
Field Value
Type | Description |
---|---|
ComponentTypeSerializationStrategy.DefaultType |
DisplayName
The type name, unless it has a Variant (in which case it'll use the Variant Display name... assuming that is not null).
Declaration
public FixedString64Bytes DisplayName
Field Value
Type | Description |
---|---|
FixedString64Bytes |
HasDontSupportPrefabOverridesAttribute
Does this component explicitly opt-out of overrides (regardless of variant count)?
Declaration
public byte HasDontSupportPrefabOverridesAttribute
Field Value
Type | Description |
---|---|
Byte |
Hash
Hash identifier for the strategy. Should be non-zero by the time it's used in Unity.NetCode.GhostComponentSerializerCollectionData.SelectSerializationStrategyForComponentWithHash(Unity.Entities.ComponentType,System.UInt64,Unity.Collections.NativeList{Unity.NetCode.ComponentTypeSerializationStrategy}@,System.Boolean).
Declaration
public ulong Hash
Field Value
Type | Description |
---|---|
UInt64 |
IsDefaultSerializer
True if this is the "default" serializer for this component type. I.e. The one generated from the component definition itself (see GhostFieldAttribute and GhostComponentAttribute).
Declaration
public byte IsDefaultSerializer
Field Value
Type | Description |
---|---|
Byte |
Remarks
Types like Translation
don't have a default serializer as the type itself doesn't define any GhostFields, but they do have serialized variants.
IsInputBuffer
True if the code-generator determined that this is an input buffer.
Declaration
public byte IsInputBuffer
Field Value
Type | Description |
---|---|
Byte |
IsInputComponent
True if the code-generator determined that this is an input component (or a variant of one).
Declaration
public byte IsInputComponent
Field Value
Type | Description |
---|---|
Byte |
IsTestVariant
Declaration
public byte IsTestVariant
Field Value
Type | Description |
---|---|
Byte |
Remarks
True if this is an editor test variant. Forces this variant to be considered a "default" which makes writing tests easier.
PrefabType
The GhostPrefabType value set in GhostInstance present in the variant declaration. Some variants modify the serialization rules. Default is All
Declaration
public GhostPrefabType PrefabType
Field Value
Type | Description |
---|---|
GhostPrefabType |
SelfIndex
Indexer into Unity.NetCode.GhostComponentSerializerCollectionData.SerializationStrategies list.
Declaration
public short SelfIndex
Field Value
Type | Description |
---|---|
Int16 |
SendForChildEntities
True if the SendDataForChildEntity flag is true on this variant (if it has one), or this type (if not).
Declaration
public byte SendForChildEntities
Field Value
Type | Description |
---|---|
Byte |
SendTypeOptimization
Override which client type it will be sent to, if we're able to determine.
Declaration
public GhostSendType SendTypeOptimization
Field Value
Type | Description |
---|---|
GhostSendType |
SerializerIndex
Indexes into the Unity.NetCode.GhostComponentSerializerCollectionData.Serializers.
Declaration
public short SerializerIndex
Field Value
Type | Description |
---|---|
Int16 |
Remarks
Serializers are optional. Thus, 0 if this type does not serialize component data.
Properties
IsClientOnlyVariant
True if this variant is the ClientOnlyVariant.
Declaration
public readonly bool IsClientOnlyVariant { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsDontSerializeVariant
True if this variant is the DontSerializeVariant.
Declaration
public readonly bool IsDontSerializeVariant { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsSerialized
True if this variant serializes its data.
Declaration
public readonly byte IsSerialized { get; }
Property Value
Type | Description |
---|---|
Byte |
Remarks
Note that this will also be true if the type has the attribute GhostEnabledBitAttribute.
Methods
CompareTo(ComponentTypeSerializationStrategy)
Check if two VariantType are identical.
Declaration
public int CompareTo(ComponentTypeSerializationStrategy other)
Parameters
Type | Name | Description |
---|---|---|
ComponentTypeSerializationStrategy | other |
Returns
Type | Description |
---|---|
Int32 |
Implements
ToFixedString()
Logs a burst compatible debug string (if in burst), otherwise logs even more info.
Declaration
public FixedString512Bytes ToFixedString()
Returns
Type | Description |
---|---|
FixedString512Bytes | A debug string. |