Converting prefabs with GameObjectConversionSystem

It says in the manual:

It gives impression that if I have a prefab reference in my authoring component it will convert it, but it doesnt.

class TileCollectionAuthoring : MonoBehaviour
{
    public List<GameObject> tilePrefabs;
}

class TileSetConversion : GameObjectConversionSystem
{
    protected override void OnUpdate()
    {
        var tileDataList = new NativeList<TileData>(256, Allocator.Temp);
        Entities.ForEach((TileCollectionAuthoring input) =>
        {
            var tileEntity = GetPrimaryEntity(input.tilePrefabs[0]);
            Debug.Log(tileEntity);

Logs a Null entity.

What does point #2 in the manual mean?

There’s a particular ConversionSystemGroup that runs until no new references are added using DeclraeReferencedPrefab or DeclareReferencedAsset. You have to manually specify references during this phase.

Thank you. DeclraeReferencedPrefab(obj)+ [UpdateInGroup(typeof(GameObjectDeclareReferencedObjectsGroup))] Does the trick.

1 Like