- Home /
Constant Rotation with GUI.RotateAroundPivot
hello,
i have a texture that needs to rotate constantly since it's part of the loading screen.
this is my script:
var sharkSpiral : Texture2D;
var rCircle : Rect;
function OnGUI()
{
var pivot : Vector2;
pivot.x = rCircle.x+rCircle.width/2;
pivot.y = rCircle.y+rCircle.height/2;
var svMat : Matrix4x4 = GUI.matrix;
GUI.DrawTexture(rCircle,sharkSpiral);
GUIUtility.RotateAroundPivot(360,pivot);
GUI.matrix = svMat;
}
now, as far as i can see, the script is doing nothing. i can see the texture, but it doesn't rotate. i searched around for any help with GUI.RotateAroundPivot because i have the feeling that i'm missing something, but all the examples found online use the same code. i tried using another Vector2 as pivot and other random numbers for the angle, but it didn't change anything.
i also tried the code from this answer - if i change the angle in the editor it rotates for the exact amount (which is more than my code does), but it's not a constant movement.
maybe i'm misunderstanding GUI.RotateAroundPivot, but if i wanted to just rotate the texture for a bit, then i could do that in photoshop, right? no need for an extra script...
would be grateful for any help / clarification / pointers in the right direction, thanks in advance.
Answer by asafsitner · Jan 05, 2012 at 01:17 PM
Use GUIUtility.RotateAroundPivot(rotationDegree * Time.time,pivot);
Your answer
Follow this Question
Related Questions
GUI Texture Spinner - Dead Center 1 Answer
Mathf.Lerp 2 Answers
Position jitter when using GUIUtility.RotateAroundPivot 0 Answers
Rotate Texture2D 1 Answer
Making texture cover whole button 1 Answer