Unity Tutorial and Troubleshooting on Visualizing Point Cloud Data in VR
By: Mandy He (2022)
Unity Experience Expected: None
Note: This tutorial expects that you have already downloaded Unity
Step 1: Set up a new Unity Project for VR
You can follow this tutorial from the wiki or you can follow this youtube tutorial
Note that if you choose to follow the youtube tutorial, there is a custom Unity VR Template that the tutorial teaches you how to download and use in the last 2 minutes of the tutorial. This template can be very handy since you don't have to go through the process of adding the XR Interaction Toolkit each time.
NOTE: Steps 2-7 are based off this tutorial. If you have no Unity experience, I suggest that you follow that tutorial because it spends time explaining why you do each step
Step 2: DataBall Prefab
Create a prefab:
According to the tutorial linked above "create a prefab object by right-clicking in the Project window, under Assets, and selecting Create -> Prefab in the menu that opens up, and name it something meaningful, like DataBall." Then populate it with a sphere
Note that you can also do this by right-clicking in the hierarchy to create a sphere and then dragging it into your assets
Step 3: CSV Reader
Step 4: Import CSV Data
Create a folder called Resources and then store your CSV data there (aka. the data you want to visualize). The tutorial supplies you with a cleaned up dataset. Download here: iris.csv.
Step 5: DataPlotter
Create a script called DataPlotter and copy paste this code from here into the script. Note that you may need to adjust some values depending on your dataset and the values of your dataset.
Step 6: Point Holder
Create an empty GameObject called PointHolder.
Create an empty GameObject by right-clicking in the hierarchy, and clicking "create empty." Then name it PointHolder
Delete the sphere from the Hierarchy
Step 7: Plotter
Create another empty GameObject called Plotter.
Make the DataPlotter script a component of the Plotter GameObject.
Then drag the Databall prefab into the Point Prefab slot and the PointHolder GameObject into the Point Holder slot. (You will see the slot glow blue when you try to fill it with something).
Make sure to make the inputfile the name of your data file (whatever it is saved as in your resources folder)
Change Column X to 1, Column Y to 2 and Column Z to 3. (Note that this is because "0" is the index of the point but we want the actual locations of the point along the x, y, and z axis
Press the play button and after shifting around a bit you should see what is in the picture at the left.
Here are some potential tips and answers to potential questions to guide you through the scatterplot tutorial:
Ignored the standard assets package to import at the start since I could not find where to import it
Got stuck at the changing columns part because Unity for some reason read in the changes of the script but didn’t apply them when I hit play. I manually changed the Column values to what I wanted them to be in the inspector area for the Plotter game object and this seemed to fix the issue.
This seems to happen when you save your script in whatever editor you are using but you are in playmode in Unity.
The final image under step 2 seems to be wrong. The columns should be 1, 2, 3 for columnX, columnY, and columnZ respectively
If dragging the DataBall into the Point Prefab box in the inspector area doesn’t work, click on the little target next to the box, click on assets, then click on DataBall and it should work.
Small error: Note that there are two “step three”s in the tutorial
In the section “Cleanup: Instantiating Clones as Children, it tells you to instantiate another GameObject titled PointPrefab. Later you realize the author meant to call it PointHolder.
“and make sure all your curly bracket make sense- remember, these are separate methods, at the same level as Start().” -> Here i think the author means the class DataPlotter