예제 #1
0
    private void DrawLine()
    {
        Vector3 from = Vector3.zero;
        Vector3 to   = Vector3.zero;

        if (_connectable == null)
        {
            if (_selectable.selected)
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit))
                {
                    to   = new Vector3(hit.point.x, transform.position.y, hit.point.z);
                    from = transform.position;
                }
            }
        }
        else
        {
            to   = _connectable.GetPosition();
            from = transform.position;
        }
        _lineRenderer.SetPosition(0, from);
        _lineRenderer.SetPosition(1, to);
    }