docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct GhostField<InternalTypeT>

    The main way to sync state. This data will be replicated to other ghosts in an eventually consistent way. This means a client doesn't have a guarantee to receive all the different state changes, only that it'll eventually have the latest state. Your data will be rolled back automatically when running prediction. You can specify various serialization options using the FieldConfig parameter in the GhostField<InternalTypeT> constructor. Please refer to RPCs for volatile networked events. TODO-next@RPCs link to RPC doc

    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
    [Serializable]
    public struct GhostField<InternalTypeT> where InternalTypeT : unmanaged
    Type Parameters
    Name Description
    InternalTypeT

    The unmanaged type of the replicated value.

    Constructors

    GhostField(InternalTypeT, FieldConfig)

    GhostFieldAttribute

    Declaration
    public GhostField(InternalTypeT initialValue = default, FieldConfig fieldConfig = null)
    Parameters
    Type Name Description
    InternalTypeT initialValue

    The value the field holds until it is linked to its ghost entity.

    FieldConfig fieldConfig

    Serialization options used by source generators.

    Properties

    Value

    Access your stored networked value. Optional: To access ECS Component data from ECS systems, please use GhostComponentRef<TComponentType>

    Declaration
    public InternalTypeT Value { get; set; }
    Property Value
    Type Description
    InternalTypeT
    In This Article
    Back to top
    Copyright © 2026 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)