I get this error when building but not in the Editor in AssetImportWorker0:
InvalidOperationException: Entity Entity(20:1) doesn't belong to the current authoring component. GameObject 'TestEnemyAuthoring' in Scene
Here's the authoring script:
using UnityEngine;
using Unity.Entities;
public class TestPrefabAuthoring : MonoBehaviour
{
public GameObject TestPrefab;
}
public class TestPrefabBaker : Baker<TestPrefabAuthoring>
{
public override void Bake(TestPrefabAuthoring authoring)
{
Entity entity = GetEntity(TransformUsageFlags.Dynamic);
var prefab = GetEntity(authoring.TestPrefab, TransformUsageFlags.Dynamic);
AddComponent(entity, new TestComponent
{
TestEntity = prefab
});
}
}```
Here's the component script:
```cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Entities;
public struct TestComponent : IComponentData
{
public Entity TestEntity;
}
Here's the prefab and the player in subscene that's referencing it to use it:
