Draw a Line to AR World- App Dev Series 18

Objective: quick intro of LineRenderer in Unity.

LineRenderer is a component that would let your drawing lines in Unity.
In this tutorial, we would take a quick demonstrate of how to draw a line from UI to 3D object that on a AR scanning target.


To draw a line using LineRenderer, you need to have the Vector3 data from both target object. Let’s get the Vector3 on the UI target and 3D object.

Create a new UI Canvas and change the render mode to “Screen Space- Camera”. Then assign the AR camera to it.

Inside this Canvas, create an image object with a text object in it. This is the label that would be connected to 3D object by LineRenderer.

Then create a sphere on 3D model. You can see it as a label mark would pop up the information column.


Now we got all the objects we needed. Add a LineRenderer component in label object.

Add a script in Label object to draw the line object.
Inside the script, get the reference of LineRenderer and Label. Once we get the reference, we need to set the width of line on both dots.

Then we can draw a line in Update().

And don’t forget to attach the LineRenderer and sphere object in editor.

Now would be a good time to open your camera and test it out!

A passionate gamer whose goal is to work in video game development.