public IEnumerator AnimateIteration(MeshIterator iterator)
    {
        InProgress = true;
        IterationElements.ForEach(a => a.AddToMesh());
        iterator.meshContainer.UpdateMesh();

        var timer = 0.0f;

        while (timer < 1)
        {
            var tick = Time.deltaTime / iterator.meshContainer.IterationSpeed;
            timer = 1 - timer <= tick * 2 ? 1 : timer + tick;

            foreach (var ie in IterationElements)
            {
                foreach (var fv in ie.floatingVerts)
                {
                    iterator.meshContainer.Vertices[fv.copyLayer.parentIndex] = Vector3.Lerp(fv.StartPosition, fv.meshVert.Position, EasingCurves.easeOutCubic(0, 1, timer));
                }
            }

            iterator.meshContainer.UpdateVertices();

            yield return(null);// new UnityEngine.WaitForEndOfFrame();
        }

        foreach (var ie in IterationElements)
        {
            ie.RemoveUniqueVertices();
        }

        InProgress = false;
    }
Example #2
0
    public void Start()
    {
        iterator                = new MeshIterator(this);//, IterationTime, IterationSpeed
        meshFilter              = GetComponent <MeshFilter>();
        meshCollider            = GetComponent <MeshCollider>();
        meshCollider.sharedMesh = meshFilter.mesh;

        //if (clearOnStart)
        meshFilter.mesh.Clear();

        Init(2);
    }