GUIUtility.RotateAroundPivot issue

I have some trouble with using GUIUtility.RotateAroundPivot inside GUI.BeginGroup/GUI.EndGroup.

The schema of code is like this:

var matrixBackup = GUI.matrix;
GUI.matrix = matrixBackup;

The result is:


The root of issue is :

  1. At first step Unity draws texture and cut it by GUI.BeginGroup/GUI.EndGroup borders.
  2. And after that Unity rotate texture and show it on screen.

This leads to the wrong green radar behavior - it sticks out of the map.

How should I rotate green texture to avoid this issue?

bug confirmed still in Unity 4.0.7f

Very helpful. I had issues rotating GUITextures, then used this code as a guide. I place the Group at the end of my code mostly, and rotate around the pivot (a little complex but makes a ton of sense after you play with it). Great for animating simple GUI textures (such as radar sweeps, clock hands, compass rose/needle, eyeballs, solar systems/planets/orbitals, etc.)

in C#, I’m doing something along these lines:

private static int rotationAngle = 0;

void onGUI() {
	GUI.BeginGroup(new Rect(0,0,Screen.width,Screen.height));
	rotationAngle += 5;
	GUIUtility.RotateAroundPivot(rotationAngle , new Vector2(Screen.width/2, Screen.height/2));
	GUI.DrawTexture(new Rect(Screen.width/2 - 128, Screen.height/2 - 128, 256, 256), myRotatingTexture);

…where myRotatingTexture is a texture object, loaded via WWW, resource load, etc. Also, I’m using a 256/256 texture (hence the 128 and 256 entries for width/height/position) and rotating around the center of the screen. You can modify this to rotate around a different point, but it does work nicely!

Remember the pivot point is relative to wherever you place the texture on the X/Y grid, so if you place a texture at x:100, y:100, and you want a 256x256 texture to rotate at the center, you would set your 2nd parameter of RotateAroundPivot to Vector2(128,128,256,256) (relative to the texture position).