makeLine.addNewLine C# (CSharp) Method

addNewLine() public method

public addNewLine ( GameObject brush ) : void
brush GameObject
return void
    public void addNewLine(GameObject brush)
    {
        int lineCount = lines.Count;
        int pointCount = (lineCount > 0) ? (lines [lineCount - 1].points.Count) : 0;
        if (lineCount > 0 && pointCount > 0) {
            Point p = new Point ();
            p.pos = lines [lineCount - 1].points [pointCount - 1].pos;
            p.parent = lines [lines.Count - 1];
            lines [lines.Count - 1].points.Add (p);
        }
        Line l = new Line ();
        l.points = new List<Point> ();
        l.opacity = 1f;
        Point p0 = new Point ();
        p0.pos = brush.transform.position;
        p0.color = color;
        p0.parent = l;
        p0.width = 50;
        l.points.Add (p0);
        lines.Add (l);
    }

Usage Example

Example #1
0
        public void addLine()
        {
            if (lines.Count < 1)
            {
                lines.Add(Instantiate(line));
            }
            makeLine other = (makeLine)lines[0].GetComponent(typeof(makeLine));

            other.addNewLine(brush);
            other.maxPoints = maxVertexCount;
            //		lines.Add(Instantiate(line));
        }