Unity3D Vectrosity 3.0 Line between GameObject and UI item

Viewed 1569

I'm using Vectrosity to draw a line between my 3D GameObject and a UI element. However, I'm struggling to convert the RectTransform position data so I can pass it to the drawline function.

I've been experimenting with getting the RectTransform position of my desired UI elements and trying to draw a line between them. However, this doesn't work. When I change the code to make use of normal 3D objects in my scene, the line appears as intended. This is the code that I currently have been playing with:

  void Start ()
{

  //  points[0] = image.rectTransform.transform.position;
  //  points[1] = image2.rectTransform.transform.position;

    points[0] = obj1.transform.position;
    points[1] = obj2.transform.position;

    line = new VectorLine("Line", points, mat, 2.0f, LineType.Continuous);
    VectorLine.canvas.sortingOrder = 1;
    VectorLine.SetCanvasCamera(Camera.main);

}

// Update is called once per frame
void Update () {
    line.Draw();

}

The first commented out line get the positions of my 2 UI objects fine, but nothing appears on the screen. The uncommented out line work fine. Is there something I'm doing wrong here?

All of the above is done in a 3D scene. I'll be having my camera orbit, rotate and zoom around the 3D object and would like the line to remain consistent

0 Answers
Related