- Home /
GUI Texture Spinner - Dead Center
I'm using a 32x32 texture2d that's basically a refresh circle, with the circle being dead center at 16,16 on the graphic. However, when I try spinning it with the below snippet, the pivot point is off, and the circle doesn't spin locally, but "precesses"... I'm wondering if this is because the pivot center keeps changing - or if this is somehow not dead center?
var spinner:Texture2D; var rotAngle:int; var pivotPoint:Vector2;
function Start(){pivotPoint = Vector2(Screen.width/2,Screen.height/2);}
function OnGUI () { GUIUtility.RotateAroundPivot (rotAngle, pivotPoint); GUI.Label(Rect(Screen.width/2-16, Screen.height/2-16,32, 32),spinner); rotAngle += 1;
}
Answer by ina · Sep 05, 2011 at 10:31 PM
Apparently it's an issue with the default gui.skin having non-zero padding and margin. Assigning a zero-ed out GUI.skin fixed it!
Your answer
Follow this Question
Related Questions
Constant Rotation with GUI.RotateAroundPivot 1 Answer
How Do I Center A GUI Label? 5 Answers
GUI Cross Hair Positioning 1 Answer
My OnGUI() Won't show the Button elements :( 0 Answers
Draw crosshair INSTEAD of cursor. 1 Answer