Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Based on the script found here: http://weeklycoder.com/2015/08/13/make-a-circle-using-linerenderer-in-unity/
- public static void CreateCircle(this LineRenderer line, int segments, float radius)
- {
- line.CreateCircle(segments, radius, radius);
- }
- public static void CreateCircle(this LineRenderer line, int segments, float xRadius, float yRadius)
- {
- line.SetVertexCount(segments + 1);
- line.useWorldSpace = false;
- float x;
- float y;
- float z = 0f;
- float angle = 20f;
- for (int i = 0; i < segments + 1; i++)
- {
- x = Mathf.Sin(Mathf.Deg2Rad * angle) * xRadius;
- y = Mathf.Cos(Mathf.Deg2Rad * angle) * yRadius;
- line.SetPosition( i, new Vector3(x,y,z) );
- angle += 360f / segments;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement