protected override void OnDestroy()
 {
     if (_transformAa.isCreated)
     {
         _transformAa.Dispose();
     }
 }
Esempio n. 2
0
    void RemoveShipsFromList()
    {
        foreach (Boid ship in shipsToDestroy)
        {
            // Get ship no
            int shipNo = ships.IndexOf(ship);

            // Remove ship from list
            ships.RemoveAt(shipNo);
            shipComp.RemoveAt(shipNo);

            // Recreate the velocities array
            List <Vector3> tempVelocities = new List <Vector3>(velocities.ToArray());
            tempVelocities.RemoveAt(shipNo);
            velocities.Dispose();
            velocities = new NativeArray <Vector3>(ships.Count, Allocator.Persistent);
            velocities.CopyFrom(tempVelocities.ToArray());

            // Remove from transfrom access array
            transformAccessArray.Dispose();
            Transform[] tempTransforms = new Transform[ships.Count];
            for (int i = 0; i < ships.Count; i++)
            {
                tempTransforms[i] = ships[i].transform;
            }
            transformAccessArray = new TransformAccessArray(tempTransforms);
        }
        shipsToDestroy.Clear();
    }
Esempio n. 3
0
 private void OnDisable()
 {
     MovementJobHandle.Complete();
     _transforms.Dispose();
     _movementInfoArray.Dispose();
     _instance = null;
 }
Esempio n. 4
0
        protected void OnDestroy()
        {
            if (NodeTransformArray.isCreated)
            {
                NodeTransformArray.Dispose();
            }

            ClearGraph();
            Graphs.Remove(this);
        }
Esempio n. 5
0
    private void OnDestroy()
    {
        startConnectionsIndex.Dispose();
        nodeNumConnections.Dispose();
        allNodeConnections.Dispose();
        allRestsDistances.Dispose();

        gn1Index.Dispose();
        gn2Index.Dispose();
        gn1VertexStartIndices.Dispose();
        gn2VertexStartIndices.Dispose();
        lineWidths.Dispose();
        baseLineWidths.Dispose();
        coordinates.Dispose();

        drawables.Dispose();

        offsets.Dispose();
        prevPositions.Dispose();
        positions.Dispose();
        newPositions.Dispose();
        affected.Dispose();
        accelerations.Dispose();
        targetPositions.Dispose();
        returnPositions.Dispose();
        moveables.Dispose();
        m_GravMesh.vertices.Dispose();
        m_MeshMatcher.Cleanup();
        forceUpdatePosition.Dispose();
        colliderTransformArray.Dispose();
    }
Esempio n. 6
0
 private void OnDestroy()
 {
     _positions.Dispose();
     _velocities.Dispose();
     _accelerations.Dispose();
     _transformAccessArray.Dispose();
 }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        Transform[] transforms = new Transform[people.Count];
        float[]     influence  = new float[people.Count];
        for (int i = 0; i < people.Count; i++)
        {
            transforms[i] = people[i].transform;
            influence[i]  = people[i].influenceLevel;
        }
        TransformAccessArray transformAccessArray = new TransformAccessArray(transforms, 100);
        NativeArray <float>  influenceNA          = new NativeArray <float>(influence, Allocator.TempJob);
        ApplyInfluenceJob    applyInfluenceJob    = new ApplyInfluenceJob
        {
            baseMovement = 1,
            deltaTime    = Time.deltaTime,
            sin          = math.sin(Time.time),
            Influence    = influenceNA,
            random       = new Unity.Mathematics.Random((uint)UnityEngine.Random.Range(1, 100000))
        };
        JobHandle handle = applyInfluenceJob.Schedule(transformAccessArray);

        handle.Complete();
        transformAccessArray.Dispose();
        influenceNA.Dispose();
    }
Esempio n. 8
0
 private void OnDestroy()
 {
     jobHandle1.Complete();
     //JobHandle.CompleteAll(jobHandle1);
     accessArray.Dispose();
     Velocities.Dispose();
 }
Esempio n. 9
0
        public void Destroy()
        {
            if (transformAccess.isCreated)
            {
                transformAccess.Dispose();
            }

            activeCount = 0;

            if (!AssetOnly)
            {
                foreach (var obj in objectInsideThisPool)
                {
                    if (obj != null)
                    {
                        GameObject.Destroy(obj);
                    }
                }

                objectInsideThisPool = null;
                if (root != null && root.gameObject != null)
                {
                    GameObject.Destroy(root.gameObject);
                }
            }

            asset           = null;
            delayedCommands = null;
            oneFrameDelay   = false;
        }
Esempio n. 10
0
 private void OnDestroy()
 {
     if (_NativeTransforms.isCreated)
     {
         _NativeTransforms.Dispose();
     }
 }
Esempio n. 11
0
    /// <summary>
    /// create a job for transform position all enimies with speed
    /// </summary>
    private void JobWorkToTransform()
    {
        NativeArray <float>  speedArr             = new NativeArray <float>(enemies.Count, Allocator.TempJob);
        TransformAccessArray transformAccessArray = new TransformAccessArray(enemies.Count);

        for (int i = 0; i < enemies.Count; i++)
        {
            speedArr[i] = enemies[i].speed;
            transformAccessArray.Add(enemies[i].transform);
        }

        UpdateTransform job = new UpdateTransform
        {
            deltaTime  = Time.deltaTime,
            speedArray = speedArr,
            targetX    = _targetX,
        };

        JobHandle jobHandle = job.Schedule(transformAccessArray);

        jobHandle.Complete();

        speedArr.Dispose();
        transformAccessArray.Dispose();
    }
Esempio n. 12
0
        public void AddNewColumn(OreColumn oreColumn)
        {
            audioSourceEffects.PlayOneShot(addColumnSound);

            var columnHolder = InstantiateColumn(oreColumn);

            columnHolder.transform.SetAsFirstSibling();
            columnHolder.transform.localPosition = new Vector3(-1 * _prefabSize.x, 0, 0);

            var transformAccessArray = new TransformAccessArray(_game.GetOreColumns().Count);

            for (int i = 0; i < spawnPoint.transform.childCount; i++)
            {
                transformAccessArray.Add(spawnPoint.transform.GetChild(i));
            }

            new MoveColumnsLeftJob
            {
                PrefabWidth = _prefabSize.x
            }
            .Schedule(transformAccessArray)
            .Complete();

            transformAccessArray.Dispose();
        }
Esempio n. 13
0
    private void Clear()
    {
        if (spawnObjects == null || spawnObjects.Count == 0)
        {
            return;
        }

        Debug.Log("JobMoveSample.Clear");
        if (transformAccessArray.isCreated)
        {
            transformAccessArray.Dispose();
        }
        if (moveDirections.IsCreated)
        {
            moveDirections.Dispose();
        }
        if (rotateAngles.IsCreated)
        {
            rotateAngles.Dispose();
        }

        for (int i = spawnObjects.Count - 1; i >= 0; i--)
        {
            if (spawnObjects[i] != null)
            {
                Destroy(spawnObjects[i]);
            }
        }
        spawnObjects.Clear();

        DisplayCount();
    }
Esempio n. 14
0
 private void OnDestroy()
 {
     JobHandle.ScheduleBatchedJobs();
     JobHandle.CompleteAll(ref _moveJob, ref _updateTransformJob);
     _positions.Dispose();
     _transforms.Dispose();
 }
Esempio n. 15
0
 void Update()
 {
     //按下鼠标左键后
     if (Input.GetMouseButtonDown(0))
     {
         //随机设置坐标
         NativeArray <Vector3> position = new NativeArray <Vector3>(cubes.Length, Allocator.Persistent);
         for (int i = 0; i < position.Length; i++)
         {
             position[i] = Vector3.one * i;
         }
         //设置Transform
         TransformAccessArray transformArray = new TransformAccessArray(cubes);
         //启动工作线程
         MyJob job = new MyJob()
         {
             position = position
         };
         JobHandle jobHandle = job.Schedule(transformArray);
         //等待工作线程结束
         jobHandle.Complete();
         Debug.Log("工作线程结束");
         //结束
         transformArray.Dispose();
         position.Dispose();
     }
 }
Esempio n. 16
0
 private void OnDestroy()
 {
     cloudsTransforms.Dispose();
     cloudsSpeeds.Dispose();
     cloudsDirs.Dispose();
     dirsResult.Dispose();
 }
Esempio n. 17
0
 public void Destroy()
 {
     currentSpectrums.Dispose();
     prevSpectrums.Dispose();
     origins.Dispose();
     transformsAccess.Dispose();
 }
Esempio n. 18
0
 private void OnDestroy()
 {
     JobHandle.ScheduleBatchedJobs();
     JobHandle.CompleteAll(ref _MoveJob, ref _SceneJob);
     _Transforms.Dispose();
     _Positions.Dispose();
 }
Esempio n. 19
0
 private void OnDisable()
 {
     if (collisiderParents.isCreated)
     {
         collisiderParents.Dispose();
     }
 }
 protected virtual void OnDisable()
 {
     _snapArrowsToFloorJobHandle.Complete();
     _snapTrajectoriesToFloorJobHandle.Complete();
     _arrowTransforms.Dispose();
     _trajectoryTransforms.Dispose();
 }
Esempio n. 21
0
    private void Update()
    {
        float startTime = Time.realtimeSinceStartup;

        //Objenin sürekli hareket halinde olmasını sağlamak için gerekli tanımları yaptık
        NativeArray <float>  moveYArray           = new NativeArray <float> (BodyList.Count, Allocator.TempJob);
        TransformAccessArray transformAccessArray = new TransformAccessArray(BodyList.Count);

        for (int i = 0; i < BodyList.Count; i++)
        {
            moveYArray[i] = BodyList[i].moveY;
            transformAccessArray.Add(BodyList[i].transform);
        }

        ReallyToughParallelJobTransforms reallyToughParallelJobTransforms = new ReallyToughParallelJobTransforms {
            deltaTime  = Time.deltaTime,
            moveYArray = moveYArray,
        };

        JobHandle jobHandle = reallyToughParallelJobTransforms.Schedule(transformAccessArray);

        jobHandle.Complete();

        for (int i = 0; i < BodyList.Count; i++)
        {
            BodyList[i].moveY = moveYArray[i];
        }

        moveYArray.Dispose();
        transformAccessArray.Dispose();

        txtTotal.text = "TOTAL\n" + GameObject.FindGameObjectWithTag("bodies").transform.childCount.ToString();   //Obje sayısını güncel tuttuk
    }
Esempio n. 22
0
 public void Dispose()
 {
     if (Data.isCreated)
     {
         Data.Dispose();
     }
 }
Esempio n. 23
0
 /// <summary>
 /// 释放,如果为true,则重新加载数据
 /// 注意,该操作会释放大量GC
 /// </summary>
 /// <param name="isReset"></param>
 public void Dispose(bool isReset)
 {
     Hjob.Complete();
     pointReadList.Dispose();
     pointReadWriteList.Dispose();
     pointTransformsList.Dispose();
     constraintReadList1.Dispose();
     for (int i = 0; i < constraintReadList.Length; i++)
     {
         constraintReadList[i].Dispose();
     }
     if (isReset)
     {
         pointTransformsList  = new TransformAccessArray(0);
         m_constraintList     = new List <ConstraintRead[]>();
         m_pointReadList      = new List <PointRead>();
         m_pointReadWriteList = new List <PointReadWrite>();
     }
     else
     {
         collidersReadList.Dispose();
         collidersReadWriteList.Dispose();
         colliderTransformsList.Dispose();
     }
 }
Esempio n. 24
0
 private void LateUpdate()
 {
     trans = new TransformAccessArray(transforms[num].Count, -1);
     trans.SetTransforms(transforms[num].ToArray());
     fl = new NativeArray <float>(vs[num].Count, Allocator.Temp);
     fl.CopyFrom(vs[num].ToArray());
     billJob = new BillBoardJob()
     {
         camPos       = transform.position,
         spriteNum    = new NativeArray <int>(spr.Length, Allocator.Temp),
         spriteLength = sprites.Length,
         rot          = fl
     };
     handle = billJob.Schedule(trans);
     handle.Complete();
     for (int i = 0; i < trans.length; i++)
     {
         transforms[num][i].GetComponent <Renderer>().material = sprites[billJob.spriteNum[i]];
     }
     if (num < 9)
     {
         num++;
     }
     else
     {
         num = 0;
     }
     fl.Dispose();
     trans.Dispose();
     billJob.spriteNum.Dispose();
 }
Esempio n. 25
0
 private void OnDisable()
 {
     // Ensure all jobs are finished before class is disabled
     blockJobHandle.Complete();
     // Free up memory
     blockAccessArray.Dispose();
 }
 void OnDisable()
 {
     jobHandle.Complete();
     transforms.Dispose();
     velocity.Dispose();
     angularVelocity.Dispose();
 }
Esempio n. 27
0
 /// <summary>
 /// 释放,如果为true,则重新加载数据
 /// 注意,该操作会释放大量GC
 /// </summary>
 /// <param name="isReset"></param>
 public void Dispose(bool isReset)
 {
     JobHandle.CompleteAll(handleList.AsArray());
     pointReadList.Dispose();
     pointReadWriteList.Dispose();
     pointTransformsList.Dispose();
     constraintReadList1.Dispose();
     ConstraintReadByPointIndex.Dispose();
     for (int i = 0; i < constraintReadList.Length; i++)
     {
         constraintReadList[i].Dispose();
     }
     if (isReset)
     {
         pointTransformsList  = new TransformAccessArray(0);
         m_constraintList     = new List <ConstraintRead[]>();
         m_pointReadList      = new List <PointRead>();
         m_pointReadWriteList = new List <PointReadWrite>();
     }
     else
     {
         handleList.Dispose();
         collidersReadList.Dispose();
         collidersReadWriteList.Dispose();
         colliderTransformsList.Dispose();
     }
 }
Esempio n. 28
0
 public void OnDestroy()
 {
     transforms.Dispose();
     theta.Dispose();
     angle.Dispose();
     frequency.Dispose();
 }
Esempio n. 29
0
    private void Update()
    {
        float startTime = Time.realtimeSinceStartup;

        if (useJobs)
        {
            //NativeArray<float3> postions = new NativeArray<float3>(prefabs.Count, Allocator.TempJob);
            NativeArray <float>  speeds = new NativeArray <float>(prefabs.Count, Allocator.TempJob);
            TransformAccessArray trans  = new TransformAccessArray(prefabs.Count);
            for (int i = 0; i < prefabs.Count; i++)
            {
                //postions[i] = prefabs[i].trans.localPosition;
                trans.Add(prefabs[i].trans);
                speeds[i] = prefabs[i].speed;
            }
            //ReallyToughParallelJob job = new ReallyToughParallelJob()
            ReallyToughTransJob job = new ReallyToughTransJob()
            {
                //positionArray = postions,
                speedArray = speeds,
                deltaTime  = Time.deltaTime
            };
            //JobHandle handle = job.Schedule(prefabs.Count, 100);
            JobHandle handle = job.Schedule(trans);
            handle.Complete();
            for (int i = 0; i < prefabs.Count; i++)
            {
                //prefabs[i].trans.localPosition = postions[i];
                //prefabs[i].trans = trans[i];
                prefabs[i].speed = speeds[i];
            }
            //postions.Dispose();
            speeds.Dispose();
            trans.Dispose();
        }
        else
        {
            ReallyToughMoveTask();
        }

        /*if (!useJobs)
         * {
         *  for (int i = 0; i < 10; i++)
         *  {
         *      ReallyToughTask();
         *  }
         * }
         * else
         * {
         *  NativeList<JobHandle> handles = new NativeList<JobHandle>(Allocator.Temp);
         *  for (int i = 0; i < 10; i++)
         *  {
         *      JobHandle handle = ReallyToughrJobTask();
         *      handles.Add(handle);
         *  }
         *  JobHandle.CompleteAll(handles);
         *  handles.Dispose();
         * }*/
        Debug.Log((Time.realtimeSinceStartup - startTime) * 1000 + "ms");
    }
    private void Update()
    {
        // Time.realtimeSinceStartup : 게임이 시작된 시간으로부터 경과한 실제 시간을 나타냅니다.
        float startTime = Time.realtimeSinceStartup;

        if (useJobs)
        {
            NativeArray <float>  moveYArray           = new NativeArray <float>(sphereList.Count, Allocator.TempJob);
            TransformAccessArray transformAccessArray = new TransformAccessArray(sphereList.Count);

            // List 내 위치와 moveY 저장
            for (int i = 0; i < sphereList.Count; i++)
            {
                //positionArray[i] = sphereList[i].transform.position;
                moveYArray[i] = sphereList[i].moveY;
                transformAccessArray.Add(sphereList[i].transform);
            }

            ReallyToughParalleJobTransform reallyToughParalleJobTransform = new ReallyToughParalleJobTransform
            {
                deltaTime  = Time.deltaTime,
                moveYArray = moveYArray,
            };

            JobHandle jobHandle = reallyToughParalleJobTransform.Schedule(transformAccessArray);
            jobHandle.Complete();

            for (int i = 0; i < sphereList.Count; i++)
            {
                sphereList[i].moveY = moveYArray[i];
            }

            moveYArray.Dispose();
            transformAccessArray.Dispose();
        }
        else
        {
            foreach (SphereT sphere in sphereList)
            {
                sphere.transform.position += new Vector3(0, sphere.moveY * Time.deltaTime);

                if (sphere.transform.position.y > 5f)
                {
                    sphere.moveY = -math.abs(sphere.moveY);
                }
                if (sphere.transform.position.y < -5f)
                {
                    sphere.moveY = +math.abs(sphere.moveY);
                }
                float value = 0f;
                for (int i = 0; i < 5000; i++)
                {
                    value = math.exp10(math.sqrt(value));
                }
            }
        }
        // 1 Update 경과 시간 (ms)
        Debug.Log(((Time.realtimeSinceStartup - startTime) * 1000f) + "ms");
    }