This script is supposed to draw lines that match up with the vertex positions of a separate primitive object. I’ve commented out the TextAsset that it reads the vertex positions from, and pasted the text from that into a variable to make testing easier for others.
This script is just attached to an empty GameObject for testing purposes right now.
Here’s the whole script:
//var LineList: TextAsset;
function Start(){
//this normally refers to the text asset commented out above, but I pasted the string here to make testing easier
var inString = "37|-0.5 0.0078125 -1 0.5 0.0078125 -1|-0.5 0.0078125 -1 -0.5 0.0078125 0|-0.5 0.0078125 -1 -0.5 0.0078125 -2|-0.5 0.0078125 -1 -0.75 0.0078125 -1.25|-0.5 0.0078125 -1 -0.75 0.0078125 -0.75|-0.5 0.0078125 -1 0.5 0.0078125 0|-0.5 0.0078125 -1 0.5 0.0078125 -2|-0.5 0.0078125 -1 0.75 0.0078125 -0.75|-0.5 0.0078125 -1 0.75 0.0078125 -1.25|-0.5 0.0078125 -1 -0.5 0.0078125 0|-0.5 0.0078125 -1 0.5 0.0078125 1|-0.5 0.0078125 -1 1.5 0.0078125 0|-0.5 0.0078125 -1 0.75 0.0078125 -0.25|-0.5 0.0078125 -1 -0.5 0.0078125 1|-0.5 0.0078125 -1 -1.5 0.0078125 0|-0.5 0.0078125 -1 -0.75 0.0078125 -0.25|-0.5 0.0078125 -1 -0.5 0.0078125 1|-0.5 0.0078125 -1 0.5 0.0078125 2|-0.5 0.0078125 -1 1.5 0.0078125 1|-0.5 0.0078125 -1 0.75 0.0078125 1.25|-0.5 0.0078125 -1 -0.5 0.0078125 2|-0.5 0.0078125 -1 -1.5 0.0078125 1|-0.5 0.0078125 -1 -0.75 0.0078125 1.25|-0.5 0.0078125 -1 -0.5 0.0078125 2|-0.5 0.0078125 -1 0.75 0.0078125 1.75|-0.5 0.0078125 -1 -0.75 0.0078125 1.75|-0.5 0.0078125 -1 0.5 0.0078125 -2|-0.5 0.0078125 -1 -0.75 0.0078125 -1.75|-0.5 0.0078125 -1 0.75 0.0078125 -1.75|-0.5 0.0078125 -1 1.5 0.0078125 1|-0.5 0.0078125 -1 -1.5 0.0078125 1|-0.5 0.0078125 -1 -0.75 0.0078125 -1.25|-0.5 0.0078125 -1 -0.75 0.0078125 -0.25|-0.5 0.0078125 -1 0.75 0.0078125 -0.25|-0.5 0.0078125 -1 0.75 0.0078125 -1.25|-0.5 0.0078125 -1 -0.75 0.0078125 1.75|-0.5 0.0078125 -1 0.75 0.0078125 1.75";
//split inString up
var txtLines = inString.Split("|"[0]);
//first token is the number of lines to read in data for (37 in this case)
var lineCount: int = parseInt(txtLines[0]);
var i: int = 0;
//loop through all 37 lines
for(i=1;i<=lineCount-1;i++){
//create a new child object for each line vertex pair, then add a line renderer component
var fl = new GameObject();
fl.transform.parent = transform;
var lr = fl.AddComponent(LineRenderer);
//set up the line renderer
lr.useWorldSpace = false;
lr.SetWidth(0.01, 0.01);
//each line has a start and end point only
lr.SetVertexCount(2);
//get xyz/xyz coordinate tokens for the line start/end points
var strJunk = txtLines[i].Split(" "[0]);
//convert to vector3
var startPos: Vector3 = Vector3(parseFloat(strJunk[0]), parseFloat(strJunk[1]), parseFloat(strJunk[2]));
var endPos: Vector3 = Vector3(parseFloat(strJunk[3]), parseFloat(strJunk[4]), parseFloat(strJunk[5]));
//assign positional values to the line renderer
lr.SetPosition(0, startPos);
lr.SetPosition(1, endPos);
}
//done...
}
I’m pretty sure that I’m overlooking something stupid somewhere in the code, but I can’t put my finger on it. I’ve attached a screenshot of the expected output. What I’m actually seeing in Unity is an irregular radial sunburst pattern instead.

