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);
GUI.EndGroup();
}
…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).