コード例 #1
0
        internal static unsafe JobHandle ScheduleInternal <T>(ref T jobData, ComponentGroup group, JobHandle dependsOn, ScheduleMode mode)
            where T : struct, IJobChunk
        {
            using (var chunks = group.CreateArchetypeChunkArray(Allocator.Temp))
            {
                int currentChunk  = 0;
                int currentEntity = 0;
                foreach (var chunk in chunks)
                {
                    jobData.Execute(chunk, currentChunk, currentEntity);
                    currentChunk++;
                    currentEntity += chunk.Count;
                }
            }

            return(new JobHandle());
        }
コード例 #2
0
        unsafe protected void ForEach(F_E operate, ComponentGroup group = null)
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            EntityManager.m_InsideForEach++;
            try
#endif
            {
                if (group == null)
                {
                    group = GetCachedComponentGroup_Delegate(operate);
                    if (group == null)
                    {
                        group = CreateCachedComponentGroup_Delegate(operate);
                    }
                }

                var entityType = GetArchetypeChunkEntityType();

                using (var chunks = group.CreateArchetypeChunkArray(Allocator.TempJob))
                {
                    foreach (var chunk in chunks)
                    {
                        var length = chunk.Count;

                        var entityArray = chunk.GetNativeArray(entityType);
                        for (int i = 0; i < length; ++i)
                        {
                            operate(entityArray[i]);
                        }
                    }
                }
            }
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            finally
            {
                EntityManager.m_InsideForEach--;
            }
#endif
        }