我正在开发Unity。我创建线作为名为“ out100”的游戏对象的子代。我可以用鼠标滚动单击来移动该游戏对象,右键单击来旋转它等。但是,只有我的游戏对象“ out100”在移动,而不是我的线。
foreach (KeyValuePair<string, List<Vector3>> sl in d) {
Color c1 = Color.yellow;
Color c2 = Color.red;
GameObject lines = new GameObject ();
lines.name = "lines" + sl.Key;
lines.AddComponent<LineRenderer> ();
lines.transform.SetParent (GameObject.Find ("out100").transform);
LineRenderer lineRenderer = lines.GetComponent<LineRenderer> ();
lineRenderer.material = new Material (Shader.Find ("Particles/Additive"));
lineRenderer.widthMultiplier = 0.2f;
lineRenderer.positionCount = sl.Value.Count;
float alpha = 1.0f;
Gradient gradient = new Gradient ();
gradient.SetKeys (
new GradientColorKey[] { new GradientColorKey (c1, 0.0f), new GradientColorKey (c2, 1.0f) },
new GradientAlphaKey[] { new GradientAlphaKey (alpha, 0.0f), new GradientAlphaKey (alpha, 1.0f) }
);
lineRenderer.colorGradient = gradient;
lineRenderer.GetComponent<LineRenderer> ().SetPositions (sl.Value.ToArray());
}
你知道怎么做吗?