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.

Preparation

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.

LineRenderer

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.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AWS Lambda Performance: Main Issues and How to Overcome Them

AWS Lambda Performance: Main Issues and How to Overcome Them | TechMagic.co

Top 9+ Reasons To Use React Native For Cross-Platform Mobile Apps Development

CSS Units: REM or EM?

Increase Productivity and Collaboration with Reliable Cross-Functional Teams

A group of women sitting across from each other, working together on their laptops

Fun Task using Cv2 module of Python.

Write once, store anywhere: Extensible file systems for Go

A wide variety of suitcases: all shapes, sizes, and colors.

The Role of a Scripting Language in a Conditional Authentication Scheme

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
S.J. Jason Liu

S.J. Jason Liu

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

More from Medium

Mobile Applications In Unity — Rainy Day Insurance: Creating a Case Number

Building A Stealth Game — Creating Waypoints For Your AI Guards

Adding Game Over UI elements

JavaScript to Xamarin.Forms Two Way Communication Setup