Question by
mauramo33 · Jan 24, 2016 at 04:05 PM ·
linerenderer
LineRenderer moviment problem.
Hi to all, i'm developing a 2d game but i've a problem, there's my code (it's an a prefab object):
GameObject go = new GameObject();
RectTransform rect = go.AddComponent<RectTransform>();
go.name = "moviment_" + data.mission_uid;
LineRenderer lR = go.AddComponent<LineRenderer>();
lR.material = new Material(Shader.Find("Particles/Additive"));
lR.SetColors(Color.yellow, Color.red);
lR.SetWidth(10F, 3F);
lR.SetVertexCount(data.movimentList.Moviment_Step.Count + 1);
lR.SetPosition(0, _city_origin.transform.position);
int i = 1;
foreach (Moviment_Step ms in data.movimentList.Moviment_Step)
{
GameObject city_to = GameObject.Find("obj_" + ms.object_id_end);
MapButtonController _city_to = city_to.GetComponent<MapButtonController>();
lR.SetPosition(i, _city_to.transform.position);
i += 1;
}
go.transform.SetParent(map.transform);
go.transform.position = new Vector3(0, 0, 1);
when i run these code the line was draw nice. in the position that i need. u can see the the linee was created in the right parent gameobject.
but when i move the parent (is in a scrollrect) .. all object are fixed on but not the lineRenderer.
any idea? thank you!
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612061451im_/https://answers.unity.com/themes/thub/images/avi.jpg)