/// <summary>
 /// Destroy the generated content to free up memory
 /// </summary>
 public void Dispose()
 {
     if (_error)
     {
         return;
     }
     if (extrusionSettings.bendMesh)
     {
         Destroy(extrudedMesh);
         extrusionMesh.Clear();
     }
     if (extrusionSettings.bendSprite)
     {
         Destroy(extrudedMesh);
     }
     if (extrusionSettings.meshColliderHandling == ExtrusionSettings.MeshColliderHandling.Extrude)
     {
         Destroy(extrudedCollisionMesh);
         extrusionCollisionMesh.Clear();
     }
 }
            /// <summary>
            /// Called by the extrusion sequence after extruding to apply results
            /// </summary>
            public void RuntimeApply()
            {
                if (_error)
                {
                    return;
                }
                if (extrusionSettings.ignore)
                {
                    return;
                }
                if (extrusionSettings.applyRotation)
                {
                    transform.SetPositionAndRotation(targetPosition, targetRotation);
                }
                else
                {
                    transform.position = targetPosition;
                }
                if (extrusionSettings.applyScale)
                {
                    Transform parent = transform.parent;
                    transform.parent      = null;
                    transform.localScale *= scaleMultiplier;
                    transform.parent      = parent;
                }

                if (extrusionSettings.bendMesh)
                {
                    extrudedMesh      = new Mesh();
                    extrudedMesh.name = _originalMesh.name + "_extruded";
                    extrusionMesh.WriteMesh(ref extrudedMesh);
                    MeshFilter filter = transform.GetComponent <MeshFilter>();
                    filter.sharedMesh = extrudedMesh;
                    extrusionMesh.Clear();
                }

                if (extrusionSettings.bendSprite)
                {
                    Sprite   originalSprite   = spriteRenderer.sprite;
                    Material instanceMaterial = spriteRenderer.sharedMaterial;
                    extrudedMesh      = new Mesh();
                    extrudedMesh.name = spriteRenderer.sprite.name + "_mesh";
                    Vector3[] verts     = new Vector3[extrusionSpriteVertices.Length];
                    ushort[]  shortTris = spriteRenderer.sprite.triangles;
                    int[]     tris      = new int[shortTris.Length];
                    for (int i = 0; i < tris.Length; i++)
                    {
                        tris[i] = shortTris[i];
                    }
                    for (int i = 0; i < verts.Length; i++)
                    {
                        verts[i] = extrusionSpriteVertices[i];
                    }
                    extrudedMesh.vertices  = verts;
                    extrudedMesh.uv        = extrusionSpriteUVs;
                    extrudedMesh.triangles = tris;
                    DestroyImmediate(spriteRenderer);
                    MeshRenderer spriteMeshRenderer = transform.gameObject.AddComponent <MeshRenderer>();
                    spriteMeshRenderer.sharedMaterial = instanceMaterial;
                    MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
                    spriteMeshRenderer.GetPropertyBlock(propertyBlock);
                    propertyBlock.SetTexture("_MainTex", originalSprite.texture);
                    spriteMeshRenderer.SetPropertyBlock(propertyBlock);
                    MeshFilter spriteMeshFilter = transform.gameObject.AddComponent <MeshFilter>();
                    spriteMeshFilter.sharedMesh = extrudedMesh;
                }

                switch (extrusionSettings.meshColliderHandling)
                {
                case ExtrusionSettings.MeshColliderHandling.Extrude:
                    extrudedCollisionMesh      = new Mesh();
                    extrudedCollisionMesh.name = _originalCollisionMesh.name + "_extruded";
                    extrusionCollisionMesh.WriteMesh(ref extrudedCollisionMesh);
                    meshCollider.sharedMesh = extrudedCollisionMesh;
                    break;

                case ExtrusionSettings.MeshColliderHandling.Copy:
                    if (meshCollider == null)
                    {
                        meshCollider = transform.gameObject.AddComponent <MeshCollider>();
                    }
                    if (extrudedMesh != null)
                    {
                        meshCollider.sharedMesh = extrudedMesh;
                    }
                    else
                    {
                        meshCollider.sharedMesh = _originalMesh;
                    }
                    break;
                }

#if DREAMTECK_SPLINES
                if (splineComputer != null)
                {
                    splineComputer.ResampleTransform();
                    if (extrusionSettings.bendSpline)
                    {
                        splineComputer.SetPoints(editSplinePoints);
                    }
                }
#endif
            }