docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GhostVariantsUtility

    Collection of utility that are used by the editor and runtime to compute and check ghost component variants hashes.

    Inheritance
    object
    GhostVariantsUtility
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.NetCode
    Assembly: Unity.NetCode.dll
    Syntax
    public static class GhostVariantsUtility

    Methods

    CalculateVariantHashForComponent(ComponentType)

    Calculates the "variant hash" for the component type itself, so that we can fetch the meta-data.

    Declaration
    public static ulong CalculateVariantHashForComponent(ComponentType componentType)
    Parameters
    Type Name Description
    ComponentType componentType

    The ComponentType to be used for both the component, and the variant.

    Returns
    Type Description
    ulong

    The calculated hash.

    Remarks

    It's a little odd, but the default serializer for a Component is the ComponentType itself. I.e. It is its own variant.

    UncheckedVariantHash(ulong, ComponentType)

    Calculates the "variant hash" for the variant + component pair.

    Declaration
    public static ulong UncheckedVariantHash(ulong variantTypeHash, ComponentType componentType)
    Parameters
    Type Name Description
    ulong variantTypeHash

    The hash of the Variant Type's System.Type.FullName.

    ComponentType componentType

    The ComponentType that this variant applies to.

    Returns
    Type Description
    ulong

    The calculated hash.

    UncheckedVariantHash(in FixedString512Bytes, in FixedString512Bytes)

    Calculates the "variant hash" for the variant + component pair.

    Declaration
    public static ulong UncheckedVariantHash(in FixedString512Bytes variantTypeFullName, in FixedString512Bytes componentTypeFullName)
    Parameters
    Type Name Description
    FixedString512Bytes variantTypeFullName

    The Variant Type's System.Type.FullName.

    FixedString512Bytes componentTypeFullName

    The Component Type's System.Type.FullName that this variant applies to.

    Returns
    Type Description
    ulong

    The calculated hash.

    UncheckedVariantHash(in FixedString512Bytes, ComponentType)

    Calculates a stable hash for a variant via TypeManager.GetTypeNameFixed.

    Declaration
    public static ulong UncheckedVariantHash(in FixedString512Bytes variantTypeFullName, ComponentType componentType)
    Parameters
    Type Name Description
    FixedString512Bytes variantTypeFullName

    The Variant Type's FullName.

    ComponentType componentType

    The ComponentType that this variant applies to.

    Returns
    Type Description
    ulong

    The calculated hash.

    UncheckedVariantHashNBC(string, string)

    Calculates the "variant hash" for the variant + component pair. Non-Burst Compatible version.

    Declaration
    [ExcludeFromBurstCompatTesting("Use managed types")]
    public static ulong UncheckedVariantHashNBC(string variantTypeFullName, string componentTypeFullName)
    Parameters
    Type Name Description
    string variantTypeFullName

    The Variant Type's System.Type.FullName.

    string componentTypeFullName

    The Component Type's System.Type.FullName that this variant applies to.

    Returns
    Type Description
    ulong

    The calculated hash.

    Remarks

    This method is not Burst Compatible.

    UncheckedVariantHashNBC(Type, ComponentType)

    Calculates a stable hash for a variant by combining the variant Type.Fullname and Unity.Entities.ComponentType name hash Unity.Entities.TypeManager.GetFullNameHash(Unity.Entities.TypeIndex).

    Declaration
    [ExcludeFromBurstCompatTesting("Use managed types")]
    public static ulong UncheckedVariantHashNBC(Type variantStructDeclaration, ComponentType componentType)
    Parameters
    Type Name Description
    Type variantStructDeclaration

    The Variant struct declaration type.

    ComponentType componentType

    The ComponentType that this variant applies to.

    Returns
    Type Description
    ulong

    The calculated hash.

    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)