Search Unity

Arrays, List, ... on IComponentData

Discussion in 'Entity Component System' started by xXPancakeXx, Apr 6, 2018.

  1. xXPancakeXx

    xXPancakeXx

    Joined:
    Mar 14, 2015
    Posts:
    55
    Is there any way of adding an Array, List, ... to an IComponentData?


    If not :( , is there a sneaky way of avoiding that kind of problem or do I need to store NativeArrays in the system which operates on those values?

    Example problem:
    NavMeshAgents with C# Jobs
    -> Path (is a NativeArray of PolygonIds) stored in IComponentData
     
  2. StephanK

    StephanK

    Joined:
    Jul 10, 2012
    Posts:
    47
    As someone mentioned in another Thread you can have Arrays on ISharedComponentData
     
  3. xXPancakeXx

    xXPancakeXx

    Joined:
    Mar 14, 2015
    Posts:
    55
    Yeah but that doesnt help me, because they are shared for any entities.
    I do need a different array for each entity.
     
  4. SubPixelPerfect

    SubPixelPerfect

    Joined:
    Oct 14, 2015
    Posts:
    224
    Storing any game state data in a system is ideological wrong. It violates the principles of data oriented design
     
  5. xXPancakeXx

    xXPancakeXx

    Joined:
    Mar 14, 2015
    Posts:
    55
    But if I cant store it an IComponentData and a System where to store it then?
    I guess I am a lil confused right now :)
     
    andywatts and Deleted User like this.
  6. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    As already suggested, ISharedComponentData will do the trick (i have not tried it though)
    - It can hold different data for different entities
    - The detailed documentation page provides some valuable info
    - It could be explained better, I also find the name confusing (i.e. the name suggests shared data, but the actual data can be different, i.e. you can even filter by different values)
     
    andywatts likes this.
  7. xXPancakeXx

    xXPancakeXx

    Joined:
    Mar 14, 2015
    Posts:
    55
    Lets say I put an NativeArray of an native array inside it which contains the paths of all entites processed by the system in it and I need to change the data on a regular basis doesnt that violate what is said in documentation?

    Or does this mean that I have to prevent removing SharedComponents and adding different ones to the same entity.
     
    Djayp and andywatts like this.