Created
October 16, 2014 19:21
-
-
Save abdullah353/55a553fc1836eac08c97 to your computer and use it in GitHub Desktop.
Circle From Line Renderer
From http://stackoverflow.com/questions/13708395/unity-3d-draw-circle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| float theta_scale = 0.1; //Set lower to add more points | |
| int size = (2.0 * PI) / theta_scale; //Total number of points in circle. | |
| LineRenderer lineRenderer = gameObject.AddComponent<LineRenderer>(); | |
| lineRenderer.material = new Material(Shader.Find("Particles/Additive")); | |
| lineRenderer.SetColors(c1, c2); | |
| lineRenderer.SetWidth(0.2F, 0.2F); | |
| lineRenderer.SetVertexCount(size); | |
| int i = 0; | |
| for(float theta = 0; theta < 2 * PI; theta += 0.1) { | |
| x = r*cos(theta); | |
| y = r*sin(theta); | |
| Vector3 pos = new Vector3(x, y, 0); | |
| lineRenderer.SetPosition(i, pos); | |
| i+=1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
4 years ago... but still life saving.. cheers buddy!