GhostDefaultOverridesModifier Exception with Update Components in Ghost Authoring Component

When using a GhostDefaultOverridesModifier I found that clicking the Update Components button in the Ghost Authoring Component will throw the following exception:

NullReferenceException: Object reference not set to an instance of an object
Unity.NetCode.Editor.GhostAuthoringComponentEditor.ExtractComponentInfo (UnityEngine.GameObject gameObject, Unity.NetCode.Editor.GhostAuthoringComponentEditor+SerializedComponentData& componentData) (at Packages/com.unity.netcode@0.6.0-preview.7/Editor/GhostAuthoringComponentEditor.cs:481)

This exception is only thrown when the GhostDefaultOverridesModifier does not have a GhostFieldModifier defined for one or more fields for a component.

Solution / Work around:
Defining a GhostFieldModifier for all fields in a component fixes the issue. If you have a component you do not want to sync, then set GhostFieldAttribute.SendData to false.

Either this or just add a null check in the ExtractComponentInfo method. The problem is already fixed in later NetCode versions (sorry, not available for the public yet)

1 Like