Example #1
0
    private void DeleteLastLine(Vector3 midPoint)
    {
        foreach (GameObject line in GameObject.FindGameObjectsWithTag("Line"))
        {
            Vector3 startingPoint = line.GetComponent <LineRenderer>().GetPosition(0);
            Vector3 endingPoint   = line.GetComponent <LineRenderer>().GetPosition(1);
            if (midPoint == (startingPoint + endingPoint) / 2)
            {
                //Destroy(line);
                line.GetComponent <BoxCollider>().enabled = false;
                line.GetComponent <Glow>().ChangeToDashedLine();

                meshGenerator.AddDashedLineMidpoints(midPoint);
            }
        }

        //You need to consider a series of unfolding, which means when you delete the last line, a new unfolding happens.
        //But this can be done by deleting the line after the previous unfolding finished.

        //Solution:Push the midPoint to an List, waiting to be processed.
        WaitingLines.Add(midPoint);
    }