I tried to move GUI.DragWindow() to a separate function as a way to conditionally draw a stand-alone window depending on whether the GUI element was a child of another element. Although the drag window behavior works properly, Unity generates the following recurring error at runtime:
Dragwindow can only be called within a
window callback
Is there a reason why Unity claims it can’t handle the window callback calling another function?
public delegate void AggregateDraw();
AggregateDraw standaloneWindowContent;
standaloneWindowContent = () =>
{
GUI.DragWindow();
};
public void Draw()
{
rect = GUI.Window(containerID, rect, DrawWindowContent, actionName);
}
void DrawWindowContent(int id)
{
standaloneWindowContent();
}