how to rotate a GUI.Label that is attached to a gameobject?

Hello,
I’ve been looking for a while to rotate a GUI.Label.
After reading some previous questions, I managed to do rotation but the problem is that I can’t find how to do it without moving the label to another point on the screen.
here is the code I’m using :

    var guipos:Vector3 = Camera.main.WorldToScreenPoint (transform.position);// get position to put the label
   	var pos : Vector3 = Vector3.zero; 
   	var quat : Quaternion = Quaternion.identity; //rotation for matrix
   	quat.eulerAngles = Vector3(0, 0, 45); //rotate around Z axis
   	GUI.matrix = Matrix4x4.TRS(pos, quat, Vector3.one); // change the matrix
   	GUI.Label(Rect(guipos.x,guipos.y, 2000, 200), "blabla machin truc"); 

I guess the problem is that I have to change the origin for rotation somehow…
Any help would be appreciated .
Thanks.

EDIT:

If someone could provide a link to an explanation of how the GUI.matrix works it would be great !! If I can find the logic behind it I would probably find a way out :slight_smile:

Use GUIUtility.RotateAroundPivot(). Other answers indicate that you should save and restore the GUI.matrix around the call:

var matrixBackup : Matrix4x4 = GUI.matrix;
GUIUtility.RotateAroundPivot(angle, pivot);
// Your GUI code goes here
GUI.matrix = matrixBackup;

‘pivot’ is in screen coordinates, so you will need to do the WorldToScreenPoint() as you’ve done in your code.