I am using a GUI.Window, rotated using GUIUtility.RotateAroundPivot(). I am also calling GUI.DragWindow inside the window content function to allow dragging of this window.
The window draws exactly how I want it, and can be dragged around fine most of the time. However, when the line is near vertical, the dragging turns into a massive spiral where the window quickly jumps way out of the screen.
What am I missing here? relevant drawing code is below
function Draw() {
var oldMat = GUI.matrix;
GUIUtility.RotateAroundPivot(rotationAngle, Vector2(rect.x + rect.width/2, rect.y + rect.height/2));
super.Draw();
GUI.matrix = oldMat;
}
super.Draw calls:
function Draw() {
rect = GUI.Window (winID, rect, WindowContent, GUIContent.none, GUIStyle.none);
}
and the relevent WindowContent Function is:
function WindowContent(windowID : int) {
if(annotater.currentState == toolState.nothing) {
if(IsInFocus()) {
GUI.DragWindow();
} else {
if(GUI.Button(Rect(0,0,rect.width, rect.height), GUIContent.none, GUIStyle.none)) {
annotater.SetCurrentFocus(this);
}
}
}
GUI.DrawTexture(Rect(0,0, rect.width, rect.height), GetTexture());
}