docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct GhostComponentSerializerCollectionData

    Blittable. GhostComponentSerializerCollectionSystemGroup. For internal use only.

    Implements
    IComponentData
    IQueryTypeParameter
    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    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
    ComponentType inputType

    Input type

    ComponentType 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
    ComponentTypeSerializationStrategy serializationStrategy

    Strategy to register.

    AddSerializer(State)

    Used by code-generated systems and meant for internal use only. Adds the generated ghost serializer to GhostComponentSerializer.State collection.

    Declaration
    public void AddSerializer(GhostComponentSerializer.State state)
    Parameters
    Type Name Description
    GhostComponentSerializer.State 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 InputBufferData<T>s, they'll return the variants available to their IInputComponentData authoring struct.

    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
    ComponentType 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
    NativeList<ComponentTypeSerializationStrategy>

    A list of all available variants for this componentType.

    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
    FixedString512Bytes context

    The context of this call, to aid in error reporting.

    Exceptions
    Type Condition
    InvalidOperationException

    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.

    FixedString512Bytes context

    String context

    Exceptions
    Type Condition
    InvalidOperationException

    If cannot add variant for context.

    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
    FixedString512Bytes context

    The context of this call, to aid in error reporting.

    Exceptions
    Type Condition
    InvalidOperationException

    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
    ComponentType inputType

    Component type

    ComponentType 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 SerializerIndex and that all the SerializationStrategyIndex have been set.

    Declaration
    [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")]
    public void Validate()

    Implements

    Unity.Entities.IComponentData
    Unity.Entities.IQueryTypeParameter
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)