lingyifang4

关于LinRenderer 画线

if (_star.GetComponent<LineRenderer>() == null)

{

     LineRenderer _l= _star.AddComponent<LineRenderer>();

      _l.SetColors(_color, _color);

      _l.sharedMaterial = new Material(Shader.Find("Particles/Additive"));

          _l.useWorldSpace = true;

         _l.SetWidth(start_with, end_with);

       _l.SetVertexCount(2);

        _isstartdrewline = true;

   }

else

 {

        return;

  }





    void lineRenderer()

    {        

        LineRenderer _linerenderer = _star.GetComponent<LineRenderer>();

        _linerenderer.SetPosition(0, _star.transform.position);

        Vector3 _v = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        _linerenderer.SetPosition(1, new Vector3(_v.x,_v.y,0));

    }


画线的长度是在setposition 中,0,开始位置。1为结束位置

评论