Пример #1
0
        internal InstantiateCommandBufferUntyped(Allocator allocator, FixedList64 <ComponentType> componentTypesWithData, int disposeSentinalStackDepth)
        {
            int            dataPayloadSize = 0;
            FixedListInt64 typesSizes      = new FixedListInt64();
            FixedListInt64 typesWithData   = new FixedListInt64();

            for (int i = 0; i < componentTypesWithData.Length; i++)
            {
                var size = TypeManager.GetTypeInfo(componentTypesWithData[i].TypeIndex).ElementSize;
                dataPayloadSize += size;
                typesSizes.Add(size);
                typesWithData.Add(componentTypesWithData[i].TypeIndex);
            }
            CheckComponentTypesValid(BuildComponentTypesFromFixedList(typesWithData));
            m_prefabSortkeyBlockList = (UnsafeParallelBlockList *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <UnsafeParallelBlockList>(),
                                                                                       UnsafeUtility.AlignOf <UnsafeParallelBlockList>(),
                                                                                       allocator);
            m_componentDataBlockList = (UnsafeParallelBlockList *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <UnsafeParallelBlockList>(),
                                                                                       UnsafeUtility.AlignOf <UnsafeParallelBlockList>(),
                                                                                       allocator);
            m_state = (State *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <State>(), UnsafeUtility.AlignOf <State>(), allocator);
            *m_prefabSortkeyBlockList = new UnsafeParallelBlockList(UnsafeUtility.SizeOf <PrefabSortkey>(), 256, allocator);
            *m_componentDataBlockList = new UnsafeParallelBlockList(dataPayloadSize, 256, allocator);
            *m_state = new State
            {
                typesWithData = typesWithData,
                tagsToAdd     = default,
        internal EntityOperationCommandBuffer(Allocator allocator, int disposeSentinalStackDepth)
        {
            m_blockList = (UnsafeParallelBlockList *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <UnsafeParallelBlockList>(),
                                                                          UnsafeUtility.AlignOf <UnsafeParallelBlockList>(),
                                                                          allocator);
            m_state = (State *)UnsafeUtility.Malloc(UnsafeUtility.SizeOf <State>(), UnsafeUtility.AlignOf <State>(), allocator);
            *m_blockList = new UnsafeParallelBlockList(UnsafeUtility.SizeOf <EntityWithOperation>(), 256, allocator);
            *m_state     = new State
            {
                allocator = allocator,
            };

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            DisposeSentinel.Create(out m_Safety, out m_DisposeSentinel, disposeSentinalStackDepth, allocator);

            if (s_staticSafetyId.Data == 0)
            {
                CreateStaticSafetyId();
            }
            AtomicSafetyHandle.SetStaticSafetyId(ref m_Safety, s_staticSafetyId.Data);
#endif
        }