[Resolved] Need Help with Arrays on ECS

Hello guys,

So I’m working lately with ECS and encountred a challenge which is passing arrays inside a component, i’ve read somewhere that I can put non-blittable types on an ISharedComponentData but still, it’s not working.

And also when using a NativeArray I have the following UnityError:

ArgumentException: All component types containing pointers must use a [StructLayout(LayoutKind.Explicit, Size = <multiple of 8>)] attribute such that the type's size is the same on both 32-bit and 64-bit platforms. Type 'Unity.Collections.NativeArray`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' is missing a this attribute due to pointer field 'm_Buffer'

Thanks for your help.

1 Like

Can you post a snippet of code so people can look at it.

What Entity package preview are you using? The “struct layout” issue was fixed for me in the preview33 (latest)

Not use ISharedComponentData for storing data, this is for different purposes. Look at BlobArray or DynamicBuffer instead.

1 Like

Thank you guys, it was my bad. Using
DynamicBuffer
Fixed my problem.