Class GhostAuthoringInspectionComponent
MonoBehaviour you may optionally add to any/all GameObjects in a Ghost Prefab, which allows inspecting of (and saving of) "Ghost Meta Data". E.g.
- Override/Tweak some of the component replication properties, for both child and root entities.
- Assign to each component which variant to use.
Inherited Members
Namespace: Unity.NetCode
Assembly: Unity.NetCode.Authoring.Hybrid.dll
Syntax
[DisallowMultipleComponent]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.netcode@latest/index.html?subfolder=/api/Unity.NetCode.GhostAuthoringInspectionComponent.html")]
public class GhostAuthoringInspectionComponent : MonoBehaviour
Properties
OverrideCount
Number of saved overrides on this inspection component.
Declaration
public int OverrideCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
See Also
Methods
CollectAllComponentOverridesInInspectionComponents(BaseGhostSettings, bool)
Finds all GhostAuthoringInspectionComponent's on this Ghost Authoring Prefab (including in children) and flattens their overrides into one list, paired with the GameObject each override was authored on.
Declaration
public static List<(GameObject, GhostAuthoringInspectionComponent.ComponentOverride)> CollectAllComponentOverridesInInspectionComponents(BaseGhostSettings ghostAuthoring, bool validate)
Parameters
| Type | Name | Description |
|---|---|---|
| BaseGhostSettings | ghostAuthoring | Root prefab to search from. |
| bool | validate | If true, calls LogErrorIfComponentOverrideIsInvalid() on each inspection component visited. |
Returns
| Type | Description |
|---|---|
| List<(GameObject, GhostAuthoringInspectionComponent.ComponentOverride)> | A flat list of every override across the prefab hierarchy, each paired with the GameObject that hosts the inspection component the override was authored on. |
See Also
CollectAllInspectionComponents(BaseGhostSettings)
Returns every GhostAuthoringInspectionComponent attached to
ghostAuthoring's GameObject or any descendant.
Declaration
public static List<GhostAuthoringInspectionComponent> CollectAllInspectionComponents(BaseGhostSettings ghostAuthoring)
Parameters
| Type | Name | Description |
|---|---|---|
| BaseGhostSettings | ghostAuthoring | The ghost authoring whose GameObject hierarchy is searched. |
Returns
| Type | Description |
|---|---|
| List<GhostAuthoringInspectionComponent> | A list containing the inspection components on the root GameObject followed by those on every descendant. Empty if none are present. |
See Also
EnumerateOverrides()
Read-only view of the saved overrides. Mutate via GetOrAddPrefabOverride(Type, EntityGuid, GhostPrefabType) + SavePrefabOverride(ref ComponentOverride, string) or RemoveComponentOverrideByIndex(int) so the editor's dirty/save signal fires correctly.
Declaration
public IReadOnlyList<GhostAuthoringInspectionComponent.ComponentOverride> EnumerateOverrides()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<GhostAuthoringInspectionComponent.ComponentOverride> | A read-only view backed directly by the underlying override array; iteration order is the array's storage order. |
See Also
FindExistingOverrideIndex(ref ComponentOverride)
Finds the array index of currentOverride by matching
FullTypeName (case-insensitive). Throws if not found.
Declaration
public int FindExistingOverrideIndex(ref GhostAuthoringInspectionComponent.ComponentOverride currentOverride)
Parameters
| Type | Name | Description |
|---|---|---|
| GhostAuthoringInspectionComponent.ComponentOverride | currentOverride | The override entry to locate. Passed by ref so callers holding a ref into the underlying array can ask "where am I?" without copying. |
Returns
| Type | Description |
|---|---|
| int | The position of |
Remarks
Intended for callers holding a ref obtained from GetOrAddPrefabOverride(Type, EntityGuid, GhostPrefabType) —
the entry MUST exist by construction. For non-ref lookups, use TryFindExistingOverrideIndex(Type, in EntityGuid, out int).
See Also
GetOrAddPrefabOverride(Type, EntityGuid, GhostPrefabType)
Returns the existing GhostAuthoringInspectionComponent.ComponentOverride for (managedType,
entityGuid) on this inspection component, or appends a new entry initialized with
defaultPrefabType and returns that.
Declaration
public ref GhostAuthoringInspectionComponent.ComponentOverride GetOrAddPrefabOverride(Type managedType, EntityGuid entityGuid, GhostPrefabType defaultPrefabType)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | managedType | The component type to override. Matched (case-insensitive) against FullTypeName. |
| EntityGuid | entityGuid | The entity within the prefab hierarchy this override targets. Must match either this GameObject's entity id or one of its descendants', else throws. |
| GhostPrefabType | defaultPrefabType | Initial PrefabType when a new entry is appended. Ignored when an existing entry is returned. |
Returns
| Type | Description |
|---|---|
| GhostAuthoringInspectionComponent.ComponentOverride | A ref to the existing or newly-appended override entry. Caller must call SavePrefabOverride(ref ComponentOverride, string) after mutating it. |
Remarks
Returns by ref into the underlying serialized array. The ref is invalidated by any subsequent call to GetOrAddPrefabOverride(Type, EntityGuid, GhostPrefabType) that adds a NEW entry, or by RemoveComponentOverrideByIndex(int) — both can resize the backing array. Don't hold the ref across those calls.
This operation is NOT persisted. Call SavePrefabOverride(ref ComponentOverride, string) after mutating the returned ref to flag the inspection component as dirty.
See Also
RemoveComponentOverrideByIndex(int)
Removes the override at index by swapping in the last element and resizing.
Order of remaining entries is not preserved.
Declaration
public void RemoveComponentOverrideByIndex(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Position in the override array to remove. Out-of-range indices are silently ignored when the array is empty; otherwise behaviour matches a normal indexed write to the array. |
Remarks
Invalidates any ref previously obtained from GetOrAddPrefabOverride(Type, EntityGuid, GhostPrefabType).
See Also
SavePrefabOverride(ref ComponentOverride, string)
Persists changes made to componentOverride (by-ref). If the override no
longer carries any overridden fields (HasOverriden is false), removes
it from the array entirely.
Declaration
public void SavePrefabOverride(ref GhostAuthoringInspectionComponent.ComponentOverride componentOverride, string reason)
Parameters
| Type | Name | Description |
|---|---|---|
| GhostAuthoringInspectionComponent.ComponentOverride | componentOverride | The override entry being saved, passed by ref so that auto-removal (when no fields are overridden) can resolve its index. |
| string | reason | Free-text reason for the save, useful when debugging editor undo/save flow. Not persisted. |
Remarks
At runtime this only flags the editor signal that drives a re-save; outside the editor the flag is harmless.
See Also
TryFindExistingOverrideIndex(string, in ulong, out int)
Looks up the index of the override matching managedTypeFullName +
entityGuid, if one exists. The string overload exists so callers without a runtime
Type handle (e.g. tooling reading serialized prefab data) can still query.
Declaration
public bool TryFindExistingOverrideIndex(string managedTypeFullName, in ulong entityGuid, out int index)
Parameters
| Type | Name | Description |
|---|---|---|
| string | managedTypeFullName | Component type's FullName; compared case-insensitively against FullTypeName. |
| ulong | entityGuid | The entity serial to match (mirrors Serial). |
| int | index | Set to the matching index when this method returns true; -1 otherwise. |
Returns
| Type | Description |
|---|---|
| bool | True if found; |
See Also
TryFindExistingOverrideIndex(Type, in EntityGuid, out int)
Looks up the index of the override targeting managedType on the entity
identified by guid, if one exists.
Declaration
public bool TryFindExistingOverrideIndex(Type managedType, in EntityGuid guid, out int index)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | managedType | Component type to match. FullName is compared case-insensitively against FullTypeName. |
| EntityGuid | guid | Entity identifier within the prefab; only Serial is used. |
| int | index | Set to the matching index when this method returns true; -1 otherwise. |
Returns
| Type | Description |
|---|---|
| bool | True if found; |