Example #1
0
    void Update()
    {
        Vector3[] corners = ghost.GetCorners();

        if (corners == null)
        {
            return;
        }

        line.positionCount = corners.Length;
        line.SetPositions(corners);

        line.startWidth = 0.1f;
        line.endWidth   = 0.1f;

        line.material.color = color;

        GameObject[] points = GameObject.FindGameObjectsWithTag("Point");
        foreach (GameObject point in points)
        {
            Destroy(point);
        }

        for (int i = 0; i < corners.Length; i++)
        {
            GameObject point = Instantiate(pointPrefab);
            point.transform.position = corners[i];
        }
    }