【发布时间】:2020-10-19 22:46:08
【问题描述】:
有LineRenderer的画圈代码。
但我想画多个半径不同的圆,我用了“for循环”,但有一个圆而不是多个
public float ThetaScale = 0.01f;
public float radius = 3f;
private int Size;
private LineRenderer LineDrawer;
private float Theta = 0f;
void Start ()
{
LineDrawer = GetComponent<LineRenderer>();
}
void Update ()
{
Theta = 0f;
Size = (int)((1f / ThetaScale) + 1f);
LineDrawer.SetVertexCount(Size);
for (int l = 0; l < 5; l++)
{
for(int i = 0; i < Size; i++)
{
Theta += (2.0f * Mathf.PI * ThetaScale);
float x = l * radius * Mathf.Cos(Theta);
float y = l * radius * Mathf.Sin(Theta);
LineDrawer.SetPosition(i, new Vector3(x, 0, y));
}
}
}
【问题讨论】:
-
请定义“没有结果”,你的代码没有编译,结果不是你想要的,如果不是,为什么?那种东西^^
标签: unity3d