void Start()
    {
        line = new LineMeshGenerator(width, width, 10);
        var filter = GetComponent <MeshFilter>();

        filter.mesh = line.mesh;
        GetComponent <MeshRenderer>().material = mat;
        for (int i = 0; i < positions.Length; i++)
        {
            // line.Add(positions[i]);
        }
    }
    protected void Start()
    {
        if (spline == null) {
            spline = GetComponent <SplineComponent> ();
        }

        if (spline == null) {
            Debug.LogError ("'spline' in 'SplineDrawer' is null!");
        }

        m_LineMeshGenerator = GetComponent <LineMeshGenerator> ();
        m_MeshFilter = GetComponent <MeshFilter> ();
    }
    private void DrawEaseFunction(MeshGenerationContext context)
    {
        if (_first)
        {
            _first = false;
            CaculationPoints();
        }
        var list = new List <Vertex>();
        var path = new List <LineMeshGenerator.Vertex>();

        for (int i = 0; i < _points.Count; i++)
        {
            path.Add(new LineMeshGenerator.Vertex(_points[i].x, _points[i].y));
        }
        var mesh = LineMeshGenerator.Generate(path);

        for (int i = 0; i < mesh.Count; i++)
        {
            var vert = new Vertex();
            vert.tint     = Color.white;
            vert.position = new Vector3(mesh[i].x, mesh[i].y, Vertex.nearZ);
            list.Add(vert);
        }
        var indexList = new List <ushort>();

        for (int i = 0; i < _points.Count - 1; i++)
        {
            var vertIndex = (i * 4);
            indexList.Add((ushort)vertIndex);
            indexList.Add((ushort)(vertIndex + 3));
            indexList.Add((ushort)(vertIndex + 1));
            indexList.Add((ushort)(vertIndex));
            indexList.Add((ushort)(vertIndex + 2));
            indexList.Add((ushort)(vertIndex + 3));
        }


        //for( int i = 0; i < _points.Count - 1; i++ )
        //{
        //	var dir = _points[i + 1] - _points[i];
        //	dir = dir.normalized;
        //	var vertical = NormalVector( dir );

        //	var vert1 = new Vertex();
        //	vert1.tint = Color.white;
        //	vert1.position = new Vector3( _points[i].x, _points[i].y, Vertex.nearZ );
        //	var vert2 = new Vertex();
        //	vert2.tint = Color.white;
        //	vert2.position = new Vector3( _points[i].x + vertical.x, _points[i].y + vertical.y, Vertex.nearZ );
        //	var vert3 = new Vertex();
        //	vert3.tint = Color.white;
        //	vert3.position = new Vector3( _points[i + 1].x, _points[i + 1].y, Vertex.nearZ );
        //	var vert4 = new Vertex();
        //	vert4.tint = Color.white;
        //	vert4.position = new Vector3( _points[i + 1].x + vertical.x, _points[i + 1].y + vertical.y, Vertex.nearZ );
        //	list.Add( vert1 );
        //	list.Add( vert2 );
        //	list.Add( vert3 );
        //	list.Add( vert4 );
        //}

        //var indexList = new List<ushort>();
        //for( int i = 0; i < _points.Count - 1; i++ )
        //{
        //	var vertIndex = ( i * 4 );
        //	indexList.Add( (ushort)vertIndex );
        //	indexList.Add( (ushort)( vertIndex + 3 ) );
        //	indexList.Add( (ushort)( vertIndex + 1 ) );
        //	indexList.Add( (ushort)( vertIndex ) );
        //	indexList.Add( (ushort)( vertIndex + 2 ) );
        //	indexList.Add( (ushort)( vertIndex + 3 ) );
        //}

        var data = context.Allocate(list.Count, indexList.Count);

        data.SetAllVertices(list.ToArray());
        data.SetAllIndices(indexList.ToArray());
    }