I’d Like To Know how i can Store Enteties in an Array which is part of an IComponentData struct and how i can Acces this array through the ISystem then.
Here is an example approach of mine, which somehow doesn’t work:
public class EntitesReferenceAuthoring : MonoBehaviour
{
public List<GameObject> blocks;
public class Baker : Baker<EntitesReferenceAuthoring>
{
public override void Bake(EntitesReferenceAuthoring authoring)
{
Entity entity = GetEntity(TransformUsageFlags.None);
int length = authoring.blocks.Count;
NativeArray<Entity> blocksArray = new NativeArray<Entity>(length, Allocator.Persistent);
for (int i= 0; i < length; i++)
blocksArray[i] = GetEntity(authoring.blocks[i], TransformUsageFlags.Dynamic);
AddComponent(entity, new EntitiesReference { blocks = blocksArray });
}
}
}
[ChunkSerializable]
public struct EntitiesReference : IComponentData
{
public NativeArray<Entity> blocks;
}
Are there any other ways, i don’t care weather it has to be an IComponentData i just need to store and acces the enteties through an array or list.