- Home /
Question by
mustiian · Feb 18, 2020 at 10:53 AM ·
editorscrollviewdragwindow
DragWindow doesn't work correctly with Scrollview
Hey all, I'm trying to write a node-based editor with some draggable windows and scrollable area in it. DragWindow() works fine. But if I scroll my window then created windows are not draggable. How can I fix it? Thanks
List<Rect> windows = new List<Rect>();
void OnGUI()
{
Rect workArea = new Rect(0, 0, this.position.width - 20, this.position.height - 20);
var viewSize = new Rect(0, 0, 5000, 5000);
BeginWindows();
scrollPos = GUI.BeginScrollView(workArea, scrollPos, viewSize, true, true);
for (int i = 0; i < windows.Count; i++)
{
windows[i] = GUI.Window(i, windows[i], DrawNodeWindow, "Dialogue" + i, nodeStyle);
}
if (GUI.Button(new Rect(0, 0, 80, 30), "Create Node") && Selection.activeTransform)
{
windows.Add(new Rect(10, 10, 140, 140));
}
EndWindows();
GUI.EndScrollView();
}
void DrawNodeWindow(int id)
{
GUI.DragWindow();
}
Comment