# GUI Buttons

 0 Hi,can anyone have an idea how can I draw the buttons around the circumference of the circle, Means I want to draw the buttons around the circle, where angles are constant and no of buttons are 13. more ▼ asked Jun 05 '12 at 02:00 PM gap 16 ● 2 ● 3 ● 4 I guess i know what you want, but can you please be specific? What circle? Is the circle 2d or 3d sphere? or a 3d circular plane? What do you mean by "angles are constant"? And how is the number of buttons relevant?Feel free to post a comment or edit your question Jun 05 '12 at 02:03 PM Bunny83 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 Ok, i think i finally got it what you mean ;)Well there are many ways to do something like that. Usually you would just use simple trigonometry.Since you didn't specify a language and you didn't posted any code related questions before, i will use C# ``````//C# void OnGUI() { int buttonCount = 13; float angleStep = Mathf.PI*2.0f / buttonCount; Vector2 circleCenter = new Vector2(Screen.width/2,Screen.height/2); // Set the circle radius float radius = 150; for (int i = 0; i < buttonCount; i++) { Rect R = new Rect(0,0,40,20); // adjust the size R.x = circleCenter.x + Mathf.Cos(angleStep*i)*radius - R.width/2; R.y = circleCenter.y + Mathf.Sin(angleStep*i)*radius - R.height/2; if (GUI.Button(R,"but:"+i)) { // do something } } } ``````This will draw 13 (or any other number) buttons in a circular shape.ps: if you replace the two "angleStep*i" lines with "angleStep*i + Time.time" the buttons will rotate x) more ▼ answered Jun 05 '12 at 02:59 PM Bunny83 45.1k ● 11 ● 48 ● 206 Jun 05 '12 at 03:27 PM Berenger @Berenger: That looks really nice ;)A lot people know that PI is the relation between the perimeter and the diameter of a circle, but most don't understand what that means.A circle with a diameter of 1.0 (radius 0.5) has a perimeter of PI. A unit circle (radius 1.0 --> diameter 2.0) therefore has a perimeter of 2*PI ;)There is this nice question: Place a loong rope around the earth so it (theoritically) lays flat on the surface and form a circle around the earth. Now extend the rope by 1m and lift the rope equally so it still forms a circle. At which distance is the rope levitating? ;) Jun 05 '12 at 04:23 PM Bunny83 thanks for the answers its helpful.... Jun 06 '12 at 01:41 PM gap add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email: