Instantiating entity prefab containing data of other entity prefab?

I am getting this error:

but the entity I am trying to instantiate is an entity that was created from a GameObject prefab using the ConvertToEntity script; so it should have Translation by default right?

I think I am getting this error because of the way I am getting the entity data.

Here is my setup:

  • I created a GameObject prefab (I’ll call it meteoroid), which contains the ConvertToEntity script, and a proxy mono behavior for the ISharedComponentData Destructible.

  • The Destructible proxy contains reference to two GameObject prefabs, one called HitEffect, and the other called DestroyEffect; both have the ConvertToEntity script. These are converted to entities using the GameObjectConversionSystem in the Convert method and stored in the ISharedComponentData.

  • A “Spawner” proxy mono behavior contains a reference to the meteoroid prefab and converts it to an entity and stores in the Spawner IComponentData.

  • A Spawner ComponentSystem instantiates copies of the meteoroid entity everywhere randomly.

  • If a bullet raycast hits a meteoroid, it adds a IComponentData HitData, which stores the entity it hit and hit position etc…

  • Finally, a Hit ComponentSystem looks for any entity with HitData, grabs the entity from it and gets its Destructible property. It looks through it, and instantiates either the HitEffect or DestroyEffect; this is where I am getting the error.

AddComponent does not work for me in this situation as all the other data from the prefab is also gone (including the rendering components). So I want to ask, is it possible to convert and instantiate prefabs that are stored in other converted prefabs? Or what am I doing wrong?
Here is code: gist

Okay I just found that it works only if the referenced prefab is a child of the prefab trying to reference it. I suspect it is because as soon as the “parent” prefab is converted to an entity, it somehow loses reference to where the other prefab is located. Is there a way around this, so I can have a prefab reference another prefab that are not other-wised linked?