Struct GhostVariantBakedOverride
A baking-only buffer entry that overrides how a ghost component is serialized for the prefab being baked, without forcing the user to configure a GhostAuthoringInspectionComponent by hand.
Implements
Inherited Members
Namespace: Unity.NetCode
Assembly: Unity.NetCode.Authoring.Hybrid.dll
Syntax
[BakingType]
public struct GhostVariantBakedOverride : IBufferElementData
Remarks
This is a baking-only buffer (see BakingTypeAttribute) — it is stripped before runtime and never reaches the live world.
The buffer must live on the user baker's own primary entity (Unity Entities baking forbids cross-baker writes to the same primary entity). The aggregation happens during GhostAuthoringBakingSystem, which walks the linked entity group and reads each entity's overrides.
Precedence: any matching override on the prefab's GhostAuthoringInspectionComponent wins over baker-contributed overrides. If multiple bakers happen to target the same (entity, component), the first entry encountered wins (baking is deterministic so this is stable across runs).
From a baker, call AddBuffer<GhostVariantOverride>(entity) to obtain the buffer, then use
the helper extensions on it (e.g. AppendDontSerializeOverride(DynamicBuffer<GhostVariantBakedOverride>, ComponentType, GameObject, ulong))
to construct and append entries in one call.
Fields
ComponentTypeFullNameHash
Hash of the target component type's full name. Use CalculateFullNameHash(string) on GetManagedType()'s FullName.
Declaration
public ulong ComponentTypeFullNameHash
Field Value
| Type | Description |
|---|---|
| ulong |
NoOverride
Sentinel value meaning "no override" for PrefabType and SendTypeOptimization. Matches NoOverride.
Declaration
public const int NoOverride = -1
Field Value
| Type | Description |
|---|---|
| int |
NoPrefabTypeOverride
Typed sentinel for an unset PrefabType. Use this rather than casting -1 by hand.
Declaration
public const GhostPrefabType NoPrefabTypeOverride = (GhostPrefabType)-1
Field Value
| Type | Description |
|---|---|
| GhostPrefabType |
NoSendTypeOverride
Typed sentinel for an unset SendTypeOptimization. Use this rather than casting -1 by hand.
Declaration
public const GhostSendType NoSendTypeOverride = (GhostSendType)-1
Field Value
| Type | Description |
|---|---|
| GhostSendType |
PrefabType
Override for GhostPrefabType. Cast to int and compare against NoOverride (-1) to detect "unset" (mirrors PrefabType).
Declaration
public GhostPrefabType PrefabType
Field Value
| Type | Description |
|---|---|
| GhostPrefabType |
SendTypeOptimization
Override for GhostSendType. Cast to int and compare against NoOverride (-1) to detect "unset" (mirrors SendTypeOptimization).
Declaration
public GhostSendType SendTypeOptimization
Field Value
| Type | Description |
|---|---|
| GhostSendType |
TargetEntitySerial
The serial of the target entity, mirroring Serial. Set to 0 to mean "the primary entity for the target GameObject".
Declaration
public ulong TargetEntitySerial
Field Value
| Type | Description |
|---|---|
| ulong |
TargetGameObjectInstanceId
The id of the GameObject this override targets, mirroring OriginatingEntityId.
Leave as default to mean "the entity this buffer lives on" — the common case.
Declaration
public EntityId TargetGameObjectInstanceId
Field Value
| Type | Description |
|---|---|
| EntityId |
VariantHash
The variant hash to apply, or 0 to leave the variant unchanged. Compute via ResolveVariantHashFromType(Type, ComponentType) (which honors well-known special variants like DontSerializeVariant), or UncheckedVariantHashNBC(Type, ComponentType) when you already know the variant is a user-defined struct.
Declaration
public ulong VariantHash
Field Value
| Type | Description |
|---|---|
| ulong |
Methods
ResolveSelfTargeting(ref GhostVariantBakedOverride, in EntityGuid)
If entry has the default ("self") targeting, fills both targeting fields
from hostGuid. If the user explicitly retargeted via targetGameObject,
TargetEntitySerial stays at 0 (meaning "primary entity for that GameObject") rather than
inheriting the host's serial.
Declaration
public static void ResolveSelfTargeting(ref GhostVariantBakedOverride entry, in EntityGuid hostGuid)
Parameters
| Type | Name | Description |
|---|---|---|
| GhostVariantBakedOverride | entry | Override entry to fill in. Mutated in place when its TargetGameObjectInstanceId is the default (unset). |
| EntityGuid | hostGuid | The EntityGuid of the entity the buffer lives on; used as the source for both targeting fields when self-targeting is in effect. |