An entity prefab is baked into a component using EntityPrefabReference. Then it gets loaded and ready to be instantiated. If the current scene is changed, then any attempt to instantiate the prefab will result in error
NullReferenceException: Object reference not set to an instance of an object
at Unity.Entities.AttachToEntityClonerInjection.InstantiateCompanionComponentDelegate
- Issue does not happen in the editor
- Unity 6.0.31 (but it also happens in 2022.3.x)
- Entities 1.3.8 (but it also happens with previous versions)
How to reproduce
-
Build the project
-
Press 'P' to load the prefab that uses Particles
-
Press 'Space' to change scene
-
Press 'P' again to attempt to instantiate the prefab
-
Error will show.
-
Repro project
https://mega.nz/file/0P4zVQKZ#ppnnNGlmA73PqgqNyDJdgFAfuma8DtDeBLM5rZzgeNs