- Home /
Why does my GUI.Window dragging behaviour act erratically on a rotated window?
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());
}
I am having the exact same issue, I have a dragWindow that can be rotated and once rotated near 90 degrees up to 270 degrees its freaks out like above, however once it returns to almost normal (going all the way around) it will fix itself.
Answer by Seizure · Jun 28, 2013 at 01:56 PM
http://answers.unity3d.com/questions/482482/using-guiutilityrotatearoundpivot-with-guiwindow-a.html
This answered my question which I believe is the exact same problem you had.