private void Destroy()
        {
            for (int i = 0; i < implementations.Count; ++i)
            {
                implementations[i].SetColliders(colliderShapes, colliderAabbs, colliderTransforms, 0);
                implementations[i].UpdateWorld();
            }

            // Invalidate all handles:
            if (colliderHandles != null)
            {
                foreach (var handle in colliderHandles)
                {
                    handle.Invalidate();
                }
            }

            if (rigidbodyHandles != null)
            {
                foreach (var handle in rigidbodyHandles)
                {
                    handle.Invalidate();
                }
            }

            if (materialHandles != null)
            {
                foreach (var handle in materialHandles)
                {
                    handle.Invalidate();
                }
            }

            // Dispose of all lists:
            implementations  = null;
            colliderHandles  = null;
            rigidbodyHandles = null;
            materialHandles  = null;

            if (colliderShapes != null)
            {
                colliderShapes.Dispose();
            }
            if (colliderAabbs != null)
            {
                colliderAabbs.Dispose();
            }
            if (colliderTransforms != null)
            {
                colliderTransforms.Dispose();
            }

            if (collisionMaterials != null)
            {
                collisionMaterials.Dispose();
            }

            if (rigidbodies != null)
            {
                rigidbodies.Dispose();
            }

            if (triangleMeshContainer != null)
            {
                triangleMeshContainer.Dispose();
            }
            if (edgeMeshContainer != null)
            {
                edgeMeshContainer.Dispose();
            }
            if (distanceFieldContainer != null)
            {
                distanceFieldContainer.Dispose();
            }
            if (heightFieldContainer != null)
            {
                heightFieldContainer.Dispose();
            }

            instance = null;
        }
Beispiel #2
0
 private void OnDisable()
 {
     cells.Dispose();
 }