GUI Texture rotation problem

I’m trying to implement a compas to my game so I red that I need a GUIUtility.RotateAroundPivot() function to do this. So I created a GUI texture and attached this script to it:

var cam : Transform; 
function Update () {
	GUIUtility.RotateAroundPivot(cam.rotation.y, Vector2(-550,-450)); 
}

where I set my camera as cam. That vector position is the center of the texture image in the screen. But nothing is happening… what did I do wrong?

I don’t think you can rotate Textures in unity…?

So how can I implement compas rotation?

//EDIT:

I found the solution :wink:

so what was it?

I found it on this forum. U have to create GUISkin and then a script that creates a label as abackground box as an arrow. The code looks like this:

function OnGUI () {
	  GUI.skin = compassGUISkin; 
      var compassWindowRect : Rect = Rect ((Screen.width/2)-520, Screen.height - 252, compassDiameter, compassDiameter); 
      GUI.Label (compassWindowRect, ""); 
      var cosAngle : float = Mathf.Cos(compassAngle.rotation.eulerAngles.y*Mathf.PI/180); 
      var sinAngle : float = Mathf.Sin(compassAngle.rotation.eulerAngles.y*Mathf.PI/180); 
      var xMove : float = (compassDiameter*sinAngle/2.0 + compassWidth*cosAngle/2.0); 
      var yMove : float = (-compassDiameter*cosAngle/2.0 + compassWidth*sinAngle/2.0); 
      compassPos = new Vector3((Screen.width/2)-520 + compassDiameter/2.0 + xMove,Screen.height - 252 + compassDiameter/2.0  + yMove, 0); //position for matrix 
      var compassQuat : Quaternion = Quaternion.identity; //rotation for matrix 
      compassQuat.eulerAngles = Vector3(0, 0, compassAngle.rotation.eulerAngles.y+ 90); //set the rotation to something - rotate around z! 
      GUI.matrix = Matrix4x4.TRS(compassPos, compassQuat, Vector3.one); //Apply the matrix 
      GUI.Box(Rect(0, 0, compassDiameter, compassWidth), ""); //notice how the rect starts at 0/0 and the matrix handles the position 
	  
}

Hope that will help other people with this problem :wink: