Rotate 2D Texture negative positive degrees touch

Hello,

I am working on a kind of wheel which you can rotate 360 degrees with your fingers. The positive degrees are working nicely. But the problem is, how can i make it, so when your finger goes to the left, the degrees goes negative?

Thanks in advance,
Flux

Code:

public var texture : Texture2D = null; 
public var size : Vector2 = new Vector2(128, 128); 

private var angle : float = 0; 
private var pos : Vector2 = new Vector2(0, 0); 
private var rect : Rect; 
private var pivot : Vector2; 
private var rotating : boolean = false; 
private var initialMouseAngle : float; 

function Start() { 
    UpdateSettings(); 
} 

function UpdateSettings() { 
   pos = new Vector2(180, Screen.height - texture.height + 350); 
   rect = new Rect(pos.x - size.x * 0.5f, pos.y - size.y * 0.5f, size.x, size.y); 
   pivot = new Vector2(rect.xMin + rect.width * 0.5f, rect.yMin + rect.height * 0.5f);
} 

function OnGUI() { 
   if (Application.isEditor) { UpdateSettings(); } 
    
    
   if(Input.touchCount > 0) {  
        var touch : Touch = Input.GetTouch(0); 
        var guiMouse : Vector2 = Vector2(touch.position.x, touch.position.y); 
        guiMouse.y = Screen.height - guiMouse.y; 
         
        if ((touch.phase == TouchPhase.Began) && rect.Contains(guiMouse)) { 
         var v2T : Vector2 = (guiMouse - pivot); 
         initialMouseAngle = Mathf.Atan2(v2T.y, v2T.x) - angle * Mathf.Deg2Rad; 
         rotating = true; 
        }
        else if ((touch.phase == TouchPhase.Moved) & rotating) { 
         var v2T2 : Vector2 = (guiMouse - pivot); 
         angle = (Mathf.Atan2 (v2T2.y, v2T2.x) - initialMouseAngle)  * Mathf.Rad2Deg;     
         if(angle < 0) {
            angle += 360;  
         	Debug.Log(angle);
         }
        } 
        else if ((touch.phase == TouchPhase.Ended)) { 
         rotating = false; 
         angle = 0; 
        }
   } 
    
    angle = Mathf.Clamp(angle, -360, 360);
    GUI.Label(Rect(100, 30, 100, 30), angle.ToString());
    
    var matrixBackup : Matrix4x4 = GUI.matrix; 
    GUIUtility.RotateAroundPivot(angle, pivot); 
    GUI.DrawTexture(rect, texture); 
    GUI.matrix = matrixBackup; 
}

Try setting the angle to angle % 360. The reported number will always be between 0 and 360, but the wheel should move as expected.

remove this form ur codeā€¦
if(angle < 0) {
angle += 360;