Hi, I'm trying to make a GUI weapon wheel, but why with my below code does the GUI texture draw from the middle right up and around anticlockwise, and the 2D weapon textures draw from the right middle down and around clockwise ?
function OnGUI ()
{
sectionCount = wheelTextures.length;
angleStep = Mathf.PI*2.0 / sectionCount;
circleCenter = new Vector2(Screen.width/2,Screen.height/2);
circleDirection.pixelInset.x = (circleCenter.x-circleDirection.pixelInset.width/2);
circleDirection.pixelInset.y = (circleCenter.y-circleDirection.pixelInset.height/2);
GUI.Label (Rect(circleCenter.x-stringSize.x/2, circleCenter.y-stringSize.y/2, 100, 60), message, TextStyle);
for (var j =0; j < sectionCount; j++)
{
if(touched[j])
{
if(weaponLocked)
{
wheelTextures[j].color = lockedTouchedSegmentColor;
}
else
{
wheelTextures[j].color = unlockedTouchedSegmentColor;
}
}
else
{
wheelTextures[j].color = untouchedSegmentColor;
}
wheelTextures[j].pixelInset.x = (circleCenter.x-wheelTextures[j].pixelInset.width/2) + Mathf.Cos(angleStep*j)*radius;
wheelTextures[j].pixelInset.y = (circleCenter.y-wheelTextures[j].pixelInset.height/2) + Mathf.Sin(angleStep*j)*radius;
R = new Rect(0,0,100,100);
R.x = circleCenter.x + Mathf.Cos(angleStep*j)*radius-R.width/2;
R.y = circleCenter.y + Mathf.Sin(angleStep*j)*radius-R.height/2;
GUI.DrawTexture(R, weapons[j]);
}
}
![alt text][1]
[1]: /storage/temp/48597-screen-shot-00.jpg
↧