How exactly is the data stored for a dictionary in the ECS system? If I had ComponentData like below:
namespace SomeComponent.ECS
{
[Serializable]
public struct MyNewComponent: IComponentData
{
public Dictionary<string, Vector3> Value;
}
}
Would I still benefit from organizing the data more efficiently (contiguous in memory)? Or would it basically resort back to the old component system? I also tossed a string in there to fully understand what that would do as well.
In this example am I benefiting from the ECS system?
IComponentData allows unmanaged types only. In practice this basically means: Only structs that use struct-type fields are allowed. Dictionary is a class so no go.
These are all fine:
public struct MyComponent : IComponentData
{
public float Scalar;
public float3 Vector;
public MyUnmanagedStruct CustomStruct;
}
public struct MyUnmanagedStruct
{
public byte Byte;
public Long Long;
public float3 Vector;
}
These wont compile:
public struct MyComponent : IComponentData
{
public string Text;
public int[] Array;
public Dictionary<int,float> Dictionary;
public MyManagedStruct CustomStruct;
}
public struct MyManagedStruct
{
public string Text;
public List<int> List;
public GameObject What;
}