Search Unity

[Resolved] Need Help with Arrays on ECS

Discussion in 'Entity Component System' started by karimkos, May 28, 2019.

  1. karimkos

    karimkos

    Joined:
    Dec 11, 2015
    Posts:
    2
    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.
     
    Eristen likes this.
  2. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,705
    Can you post a snippet of code so people can look at it.
     
  3. ParametrixFX

    ParametrixFX

    Joined:
    Nov 14, 2018
    Posts:
    18
    What Entity package preview are you using? The "struct layout" issue was fixed for me in the preview33 (latest)
     
  4. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    Not use ISharedComponentData for storing data, this is for different purposes. Look at BlobArray or DynamicBuffer instead.
     
    Eristen likes this.
  5. karimkos

    karimkos

    Joined:
    Dec 11, 2015
    Posts:
    2
    Thank you guys, it was my bad. Using
    DynamicBuffer
    Fixed my problem.