docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GhostComponentAttribute

    This attribute can be used to tag components to control which ghost prefab variants they are included in and where they are sent for owner predicted ghosts.

    Inheritance
    object
    Attribute
    GhostComponentAttribute
    Inherited Members
    Attribute.Equals(object)
    Attribute.GetCustomAttribute(Assembly, Type)
    Attribute.GetCustomAttribute(Assembly, Type, bool)
    Attribute.GetCustomAttribute(MemberInfo, Type)
    Attribute.GetCustomAttribute(MemberInfo, Type, bool)
    Attribute.GetCustomAttribute(Module, Type)
    Attribute.GetCustomAttribute(Module, Type, bool)
    Attribute.GetCustomAttribute(ParameterInfo, Type)
    Attribute.GetCustomAttribute(ParameterInfo, Type, bool)
    Attribute.GetCustomAttributes(Assembly)
    Attribute.GetCustomAttributes(Assembly, bool)
    Attribute.GetCustomAttributes(Assembly, Type)
    Attribute.GetCustomAttributes(Assembly, Type, bool)
    Attribute.GetCustomAttributes(MemberInfo)
    Attribute.GetCustomAttributes(MemberInfo, bool)
    Attribute.GetCustomAttributes(MemberInfo, Type)
    Attribute.GetCustomAttributes(MemberInfo, Type, bool)
    Attribute.GetCustomAttributes(Module)
    Attribute.GetCustomAttributes(Module, bool)
    Attribute.GetCustomAttributes(Module, Type)
    Attribute.GetCustomAttributes(Module, Type, bool)
    Attribute.GetCustomAttributes(ParameterInfo)
    Attribute.GetCustomAttributes(ParameterInfo, bool)
    Attribute.GetCustomAttributes(ParameterInfo, Type)
    Attribute.GetCustomAttributes(ParameterInfo, Type, bool)
    Attribute.GetHashCode()
    Attribute.IsDefaultAttribute()
    Attribute.IsDefined(Assembly, Type)
    Attribute.IsDefined(Assembly, Type, bool)
    Attribute.IsDefined(MemberInfo, Type)
    Attribute.IsDefined(MemberInfo, Type, bool)
    Attribute.IsDefined(Module, Type)
    Attribute.IsDefined(Module, Type, bool)
    Attribute.IsDefined(ParameterInfo, Type)
    Attribute.IsDefined(ParameterInfo, Type, bool)
    Attribute.Match(object)
    Attribute.TypeId
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.NetCode
    Assembly: Unity.NetCode.dll
    Syntax
    [AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct)]
    public class GhostComponentAttribute : Attribute
    Remarks

    GhostComponent is not enough to make your component replicated. Make sure to use GhostFieldAttribute on each replicated field.

    Properties

    OwnerSendType

    Get or sets if a component should be be sent to the prediction owner or not. Some combination of the parameters and OwnerSendType may result in an error or warning at code-generation time.

    Declaration
    public SendToOwnerType OwnerSendType { get; set; }
    Property Value
    Type Description
    SendToOwnerType

    PrefabType

    Gets or sets the type of prefab where this component should be included on the main entity of the prefab.

    Declaration
    public GhostPrefabType PrefabType { get; set; }
    Property Value
    Type Description
    GhostPrefabType

    SendDataForChildEntity

    Denotes whether or not this component - when added to a child entity - should send (i.e. replicate) its data. The default behaviour is that Netcode will NOT replicate component and buffer data on children. Why not? It's expensive, as it involves finding child entities in other chunks. Thus, setting this flag to true will enable this (more expensive) serialization of child entities (unless overridden via another "Variant"). Setting to false has no effect (as is the default).

    Declaration
    public bool SendDataForChildEntity { get; set; }
    Property Value
    Type Description
    bool

    SendTypeOptimization

    Gets or sets the type of ghost this component should be sent to if the ghost is owner predicted. Formerly: "OwnerPredictedSendType".

    Declaration
    public GhostSendType SendTypeOptimization { get; set; }
    Property Value
    Type Description
    GhostSendType
    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)