Anyone here with an idea why this throws no error... but the component does neither get added or set on the entity ?
internal static void AddEntityComponentCommand(this EntityCommandBufferData ecbd, EntityCommandBufferChain* chain, int sortKey, ECBCommand op, Entity e, object component){
var ctype = ComponentType.ReadWrite(component.GetType());
if (ctype.IsZeroSized) {
ecbd.AddEntityComponentTypeCommand(chain, sortKey, op, e, ctype);
return;
}
var typeSize = UnsafeUtility.SizeOf(component.GetType());
var sizeNeeded = EntityCommandBufferData.Align(sizeof(EntityComponentCommand) + typeSize, 8);
ecbd.ResetCommandBatching(chain);
var cmd = (EntityComponentCommand*)ecbd.Reserve(chain, sortKey, sizeNeeded);
cmd->Header.Header.CommandType = (int)op;
cmd->Header.Header.TotalSize = sizeNeeded;
cmd->Header.Header.SortKey = chain->m_LastSortKey;
cmd->Header.Entity = e;
cmd->ComponentTypeIndex = ctype.TypeIndex;
cmd->ComponentSize = typeSize;
byte* data = (byte*)(cmd + 1);
var objHandle = GCHandle.Alloc(component, GCHandleType.Pinned);
var adress = objHandle.AddrOfPinnedObject();
var ptr = adress.ToPointer();
Buffer.MemoryCopy(ptr, data, typeSize, typeSize);
objHandle.Free();
if (ecbd.RequiresEntityFixUp(data, ctype.TypeIndex))
{
if (op == ECBCommand.AddComponent)
cmd->Header.Header.CommandType = (int)ECBCommand.AddComponentWithEntityFixUp;
else if (op == ECBCommand.SetComponent)
cmd->Header.Header.CommandType = (int)ECBCommand.SetComponentWithEntityFixUp;
}
}