Exemple #1
0
            public void Execute(Entity entity, int index, ref Instance tester)
            {
                tester.f = time;

                DynamicBuffer <SomeFromEntityBufferElement> dynamicBuffer = someBuffer [entity];

                SomeFromEntityBufferElement bufferElement = dynamicBuffer [0];

                bufferElement.i++;                 // Increment.
                dynamicBuffer [0] = bufferElement; // Set back.

                // Console will throw error when using debug and burst is enabled.
                // Comment out Debug, when using burst.
                Debug.Log("T: " + tester.f + " IJobForEachWIthEntity " + " #" + index + "; entity: " + entity + "; " + dynamicBuffer [0].i + "; " + dynamicBuffer [1].i);
            }
Exemple #2
0
        // protected override void OnCreateManager ( int capacity ) // Obsolete
        protected override void OnCreate( )
        {
            base.OnCreate( );

            Debug.LogWarning("Burst is disabled, to use Debug.Log in jobs.");
            Debug.LogWarning("Jobs are executed approx every second.");

            Instance instance = new Instance();

            Entity entity = EntityManager.CreateEntity(typeof(Instance));

            EntityManager.SetComponentData(entity, instance);
            EntityManager.AddBuffer <SomeBufferElement> (entity);

            DynamicBuffer <SomeBufferElement> someBuffer = EntityManager.GetBuffer <SomeBufferElement> (entity);

            // Add two elements to dynamic buffer.
            SomeBufferElement someBufferElement = new SomeBufferElement();

            someBufferElement.i = 100000;
            someBuffer.Add(someBufferElement);
            someBufferElement.i = 200000;
            someBuffer.Add(someBufferElement);

            EntityManager.Instantiate(entity);     // Clone entity.


            entity = EntityManager.CreateEntity(typeof(Instance));

            EntityManager.SetComponentData(entity, instance);
            EntityManager.AddBuffer <SomeFromEntityBufferElement> (entity);

            DynamicBuffer <SomeFromEntityBufferElement> someFromEntityBuffer = EntityManager.GetBuffer <SomeFromEntityBufferElement> (entity);

            // Add two elements to dynamic buffer.
            SomeFromEntityBufferElement someFromEntityBufferElement = new SomeFromEntityBufferElement();

            someFromEntityBufferElement.i = 1000;
            someFromEntityBuffer.Add(someFromEntityBufferElement);
            someFromEntityBufferElement.i = 10;
            someFromEntityBuffer.Add(someFromEntityBufferElement);

            EntityManager.Instantiate(entity);     // Clone entity.
        }