Trouble with GUIUtility.RotateAroundPivot

Hi All,

I am having all sorts of problems trying to rotate a GUI label on the screen. The following code will work exactly as expected but only if the label is placed in the center of the screen. If labelPosition (the pivot) is anything other than the center of the screen the label winds up in some strange place. It seems that the pivot actually has something to do with the center of the screen whether you like it or not.

Help please!

var xPosition : float = Screen.width/2;
var yPosition : float = Screen.height/2;
	
function OnGUI () 
{
	GUI.skin=rulerSkin;
	var labelPosition : Vector2 = Vector2(xPosition,yPosition);	
	
	GUIUtility.RotateAroundPivot (rotateAngle,labelPosition); 
	
    GUI.Label(Rect(labelPosition.x,Screen.height-labelPosition.y,100,10),"This is the label",GUIStyle("azimuthLabel"));
    
    // reset the matrix after rotation
    GUI.matrix = Matrix4x4.identity;
}

If you want the label to rotate around its own center, then you mustn’t use the center of the screen for labelPosition. Try this (I will call R the label’s rect)

labelPosition = Vector2( R.x + R.width * 0.5, R.y + R.height * 0.5 );