Object references in a nested prefab are set to null after applying changes.
Object references can only be saved within the scope of a nested prefab. If you set an object reference to a parent or sibling of a nested prefab then the reference will be reset when saving it.
In order to properly save an object reference to a parent please follow these steps:
- Add a Prefab Overrides component to the nested prefab that contains the property with the object reference.
- Add the property as an override to the Prefab Overrides component.
- Set the correct reference in the property.
- Apply the changes using the Apply button in the inspector, or the Apply All button in the menu.
Tip: Setting an invalid object reference will show a warning in the console when applying changes.