unsafe internal ArchetypeChunkComponentObjects(int offset, int length, object[] objectArray)
        {
            Length = length;
            Offset = offset;
            Array  = null;

            var arrayPtr = (byte *)UnsafeUtility.AddressOf(ref this);

            UnsafeUtility.CopyObjectAddressToPtr(objectArray, arrayPtr + ArrayByteOffset);
        }
Example #2
0
    public static unsafe void UseBuffer <TMember>([NotNull] List <TMember> list, TMember[] buffer)
    {
        if (list == null)
        {
            throw new ArgumentNullException(nameof(list));
        }

        var ptr = (byte *)UnsafeUtility.PinGCObjectAndGetAddress(list, out var handle);

        UnsafeUtility.CopyObjectAddressToPtr(buffer, ptr + ItemsFieldOffset);
        *(int *)(ptr + SizeFieldOffset) = buffer.Length;
        UnsafeUtility.ReleaseGCObject(handle);
    }
        public void PatchManagedPtrs(int index, byte *valuePtr)
        {
            fixed(byte *cacheBytes = m_Caches)
            {
                var streams = (ComponentGroupStream *)cacheBytes;

                for (var i = m_ComponentDataCount; i != m_ComponentDataCount + m_ComponentCount; i++)
                {
                    var component         = m_ChunkIterator.GetManagedObject(m_ArchetypeManager, streams[i].TypeIndexInArchetype, CacheBeginIndex, index);
                    var valuePtrOffsetted = valuePtr + streams[i].FieldOffset;
                    UnsafeUtility.CopyObjectAddressToPtr(component, valuePtrOffsetted);
                }
            }
        }
        public unsafe void PatchManagedPtrs(int index, byte *valuePtr)
        {
            ComponentGroupStream *streamPtr = (ComponentGroupStream *)&this.m_Caches.FixedElementField;
            int componentDataCount          = this.m_ComponentDataCount;

            while (true)
            {
                if (componentDataCount == (this.m_ComponentDataCount + this.m_ComponentCount))
                {
                    fixed(byte **numPtrRef = null)
                    {
                        return;
                    }
                }
                object target  = this.m_ChunkIterator.GetManagedObject(this.m_ArchetypeManager, streamPtr[componentDataCount].TypeIndexInArchetype, this.CacheBeginIndex, index);
                byte * numPtr2 = valuePtr + streamPtr[componentDataCount].FieldOffset;
                UnsafeUtility.CopyObjectAddressToPtr(target, (void *)numPtr2);
                componentDataCount++;
            }
        }