예제 #1
0
		public void BufferFromEntityWorks()
		{
			var entityInt = m_Manager.CreateEntity(typeof(EcsIntElement));
            m_Manager.GetBuffer<EcsIntElement>(entityInt).CopyFrom(new EcsIntElement[] { 1, 2, 3 });

			var intLookup = EmptySystem.GetBufferFromEntity<EcsIntElement>();
			Assert.IsTrue(intLookup.Exists(entityInt));
			Assert.IsFalse(intLookup.Exists(new Entity()));

			Assert.AreEqual(2, intLookup[entityInt][1].Value);
		}
예제 #2
0
        public void SingleJobUsingSameReadOnlyDynamicBuffer()
        {
            SetupDynamicBufferJobTestEnvironment();

            var query = EmptySystem.GetEntityQuery(typeof(EcsIntElement));

            var job = new BufferSafetyJob_TwoReadOnly
            {
                BuffersFromEntity = EmptySystem.GetBufferFromEntity <EcsIntElement>(true)
            };

            job.Run(query);
        }
예제 #3
0
        public void SingleJobUsingSameReadOnlyAndReadWriteDynamicBufferThrows()
        {
            SetupDynamicBufferJobTestEnvironment();

            var query = EmptySystem.GetEntityQuery(typeof(EcsIntElement));

            var job = new BufferSafetyJob_OneRead_OneWrite
            {
                BuffersFromEntity = EmptySystem.GetBufferFromEntity <EcsIntElement>(false)
            };

            Assert.Throws <InvalidOperationException>(() =>
            {
                job.Run(query);
            });
        }
예제 #4
0
        public void TwoJobsUsingDynamicBuffersDontCauseSafetySystemFalsePositiveErrors()
        {
            SetupDynamicBufferJobTestEnvironment();

            var query = EmptySystem.GetEntityQuery(typeof(EcsIntElement));

            var jobA       = new BufferSafetyJobA();
            var jobAHandle = jobA.Schedule(query, default(JobHandle));

            var jobB = new BufferSafetyJobB
            {
                Entities          = query.ToEntityArray(Allocator.TempJob),
                BuffersFromEntity = EmptySystem.GetBufferFromEntity <EcsIntElement>(true)
            };
            var jobBHandle = jobB.Schedule(jobB.Entities.Length, 1, jobAHandle);

            jobBHandle.Complete();
        }
예제 #5
0
        public void TwoJobsUsingReadOnlyDynamicBuffersCanRunInParallel_BufferFromEntity()
        {
            SetupDynamicBufferJobTestEnvironment();

            var query = EmptySystem.GetEntityQuery(typeof(EcsIntElement));

            var jobA = new BufferSafetyJobC {
                EntityTypeHandle = m_Manager.GetEntityTypeHandle(), BufferFromEntityRO = m_Manager.GetBufferFromEntity <EcsIntElement>(true), MyArray = new NativeArray <int>(1, Allocator.TempJob)
            };
            var jobAHandle = jobA.Schedule(query, default(JobHandle));

            var jobB = new BufferSafetyJobB
            {
                Entities          = query.ToEntityArray(Allocator.TempJob),
                BuffersFromEntity = EmptySystem.GetBufferFromEntity <EcsIntElement>(true)
            };
            var jobBHandle = jobB.Schedule(jobB.Entities.Length, 1, default(JobHandle));

            jobAHandle.Complete();
            jobBHandle.Complete();
        }