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.
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.
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 “angleStepi" lines with "angleStepi + Time.time” the buttons will rotate x)