I have a couple of textures - images of stopwatch hands - that I would like to rotate within the same script.
I am using the RotateAroundPivot function to draw the stopwatch hand at the correct angle, and this works fine as long as I only call it the drawLeftStopwatch() or drawRightStopwatch() individually.
However if I include both of these functions in my code, the pivot on the second stopwatch hand appears in a completely different place to what I expect, and the hand does a kind of loop-within-a-loop. The first RotateAroundPivot is incluencing the second RotateAroundPivot in some way.
Is there a way of separating the 2 GUI groups so that the first does not influence the second’s RotateAroundPivot, within the same OnGUI function?
var _stopwatchHand: Texture;
var _rotationAngle = 0;
function Update(){
_rotationAngle += 5;
}
function OnGUI(){
// Both of these work individually, but not together
drawLeftStopwatch();
drawRightStopwatch();
}
function drawLeftStopwatch(){
GUI.BeginGroup(Rect(0,0,Screen.width, Screen.height));
GUIUtility.RotateAroundPivot(_rotationAngle , Vector2(150, 150));
GUI.DrawTexture(new Rect(300, 300, 128, 128), _stopwatchHand);
GUI.EndGroup();
}
function drawRightStopwatch(){
GUI.BeginGroup(Rect(0,0,Screen.width, Screen.height));
GUIUtility.RotateAroundPivot(_rotationAngle , Vector2(750, 750));
GUI.DrawTexture(new Rect(900, 900, 128, 128), _stopwatchHand);
GUI.EndGroup();
}