- Home /
Question by
homer_3 · Apr 23, 2019 at 12:54 AM ·
c#meshlinerenderer
LineRenderer BakeMesh is turning/rotating the line?
If I have a linerenderer that draws a line, the mesh I get after using the BakeMesh API results in a different looking line that looks like it has been rotated 90 degrees. Is there some way to get it to generate a mesh that looks exactly the same as I see it in the inspector?
To turn the line into a mesh, I'm using
public static GameObject BakeLineDebuger(GameObject lineObj, Material m)
{
var lineRenderer = lineObj.GetComponent<LineRenderer>();
var meshFilter = lineObj.AddComponent<MeshFilter>();
Mesh mesh = new Mesh();
lineRenderer.BakeMesh(mesh);
meshFilter.sharedMesh = mesh;
var meshRenderer = lineObj.AddComponent<MeshRenderer>();
meshRenderer.sharedMaterial = m;
GameObject.Destroy(lineRenderer);
return lineObj;
}
Comment
Your answer
Follow this Question
Related Questions
Generate a mesh around a LineRenderer 2 Answers
Multiple Cars not working 1 Answer
How do i cast mesh like a linerenderer? 0 Answers
Filling area under positions with Mesh 0 Answers
Distribute terrain in zones 3 Answers