Class GhostVariantOverrideBakerExtensions
Convenience extensions on Unity.Entities.DynamicBuffer<T> of GhostVariantBakedOverride that build and append entries in one call.
Inherited Members
Namespace: Unity.NetCode
Assembly: Unity.NetCode.Authoring.Hybrid.dll
Syntax
public static class GhostVariantOverrideBakerExtensions
Remarks
Typical usage from a user Baker:
public override void Bake(MyAuthoring auth)
{
var entity = GetEntity(TransformUsageFlags.None);
var overrides = AddBuffer<GhostVariantOverride>(entity);
overrides.AppendDontSerializeOverride(typeof(LocalTransform));
overrides.AppendPrefabTypeOverride(typeof(MyMarker), GhostPrefabType.Server);
}
To target a different GameObject (e.g. the root from a child baker), pass the targetGameObject parameter.
Methods
AppendDontSerializeOverride(DynamicBuffer<GhostVariantBakedOverride>, ComponentType, GameObject, ulong)
Append an override that prevents componentType from being serialized for this prefab.
Declaration
public static void AppendDontSerializeOverride(this DynamicBuffer<GhostVariantBakedOverride> buffer, ComponentType componentType, GameObject targetGameObject = null, ulong targetEntitySerial = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| DynamicBuffer<GhostVariantBakedOverride> | buffer | The baking-only override buffer (extension method receiver). |
| ComponentType | componentType | The component type to mark as non-serialized. |
| GameObject | targetGameObject | Optional retarget. If null, the override targets the primary entity of the GameObject that hosts the buffer (the common case). |
| ulong | targetEntitySerial | Optional entity serial within |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if an entry for this (componentType, target) already exists in the buffer. |
AppendOverride<TVariant>(DynamicBuffer<GhostVariantBakedOverride>, ComponentType, GameObject, ulong)
Append an override that forces componentType to use TVariant.
Declaration
public static void AppendOverride<TVariant>(this DynamicBuffer<GhostVariantBakedOverride> buffer, ComponentType componentType, GameObject targetGameObject = null, ulong targetEntitySerial = 0) where TVariant : struct
Parameters
| Type | Name | Description |
|---|---|---|
| DynamicBuffer<GhostVariantBakedOverride> | buffer | The baking-only override buffer (extension method receiver). |
| ComponentType | componentType | The component type whose serialization is being overridden. |
| GameObject | targetGameObject | Optional retarget. If null, the override targets the primary entity of the GameObject that hosts the buffer (the common case). |
| ulong | targetEntitySerial | Optional entity serial within |
Type Parameters
| Name | Description |
|---|---|
| TVariant | The variant struct type to apply. Resolved to its hash via ResolveVariantHashFromType(Type, ComponentType); well-known special variants (DontSerializeVariant, ClientOnlyVariant, ServerOnlyVariant) are honored. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if an entry for this (componentType, target) already exists in the buffer. |
AppendPrefabTypeOverride(DynamicBuffer<GhostVariantBakedOverride>, ComponentType, GhostPrefabType, GameObject, ulong)
Append an override that sets the GhostPrefabType for componentType
(e.g. Server to keep it server-only).
Declaration
public static void AppendPrefabTypeOverride(this DynamicBuffer<GhostVariantBakedOverride> buffer, ComponentType componentType, GhostPrefabType prefabType, GameObject targetGameObject = null, ulong targetEntitySerial = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| DynamicBuffer<GhostVariantBakedOverride> | buffer | The baking-only override buffer (extension method receiver). |
| ComponentType | componentType | The component type whose GhostPrefabType is being overridden. |
| GhostPrefabType | prefabType | The new GhostPrefabType value to apply. |
| GameObject | targetGameObject | Optional retarget. If null, the override targets the primary entity of the GameObject that hosts the buffer (the common case). |
| ulong | targetEntitySerial | Optional entity serial within |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if an entry for this (componentType, target) already exists in the buffer. |
AppendSendTypeOverride(DynamicBuffer<GhostVariantBakedOverride>, ComponentType, GhostSendType, GameObject, ulong)
Append an override that sets the GhostSendType optimization for componentType.
Declaration
public static void AppendSendTypeOverride(this DynamicBuffer<GhostVariantBakedOverride> buffer, ComponentType componentType, GhostSendType sendType, GameObject targetGameObject = null, ulong targetEntitySerial = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| DynamicBuffer<GhostVariantBakedOverride> | buffer | The baking-only override buffer (extension method receiver). |
| ComponentType | componentType | The component type whose GhostSendType is being overridden. |
| GhostSendType | sendType | The new GhostSendType optimization to apply. |
| GameObject | targetGameObject | Optional retarget. If null, the override targets the primary entity of the GameObject that hosts the buffer (the common case). |
| ulong | targetEntitySerial | Optional entity serial within |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if an entry for this (componentType, target) already exists in the buffer. |