Hello,
When I’m using NativeArray
inside a component created by a system, it works without any problem. But when this same component is created during the Authoring->Baking process, Entites sends me this error:
ArgumentException: Blittable component type ‘Config’ on GameObject ‘ConfigAuthoring’ contains a (potentially nested) pointer field. Serializing bare pointers will likely lead to runtime errors. Remove this field and consider serializing the data it points to another way such as by using a BlobAssetReference or a [Serializable] ISharedComponent. If for whatever reason the pointer field should in fact be serialized, add the [ChunkSerializable] attribute to your type to bypass this error.
I think it’s like a bug that it is totally allowed to use NativeArray
in Components when it’s not part of a baking process but it doesn’t work when it’s in a Baker?
Here are my following Component, Authoring and Baker:
public struct Config : IComponentData
{
public NativeArray<int> Values;
}
class ConfigAuthoring : MonoBehaviour
{
public List<int> Values;
}
class ConfigAuthoringBaker : Baker<ConfigAuthoring>
{
public override void Bake(ConfigAuthoring authoring)
{
var entity = GetEntity(TransformUsageFlags.None);
AddComponent(entity, new BattleConfig
{
Values = authoring.Values.ToNativeArray(Allocator.Temp)
});
}
}