コード例 #1
0
    IEnumerator ChangeShape(Vector3[] newShape, LINE line, float Seconds)
    {
        cycling = true;//technically this isnt the best way to handle cycling.
        float StartTime = Time.time;

        for (int i = 0; i < line.offset; i++)
        {
            Cycle(newShape);
        }
        while (Time.time - StartTime < Seconds)
        {
            if (cycle)
            {
                line.Cycle();
                Cycle(newShape);
            }
            for (int i = 0; i < 128; i++)
            {
                line.points[i] = Vector3.Lerp(line.points[i], newShape[i], (Time.time - StartTime) / (Seconds + Time.time - StartTime) / Seconds / 3);
            }
            line.SetPositions();
            yield return(null);
        }
        line.points = newShape;
        line.SetPositions();
        cycling = false;
    }
コード例 #2
0
    //function for a horizontal line

    public void horiz_line(float width, float y, LINE line, bool instant = false)
    {
        Vector3[] horiz_line = new Vector3[128];
        horiz_line[0]   = new Vector3(-width / 2, y);
        horiz_line[127] = new Vector3(width / 2, y);
        for (int i = 0; i < 128; i++)
        {
            horiz_line[i] = Vector3.Lerp(horiz_line[0], horiz_line[127], i / 127f);
        }
        if (instant)
        {
            line.points = horiz_line;
            line.SetPositions();
        }
        else
        {
            StartCoroutine(ChangeShape(horiz_line, line, 9));
        }
    }