Drawing outside/over GUI.Window

I am trying to draw a image partially outside a GUI.Window with no luck.

What I want to do in css-terms is { position: absolute; left: -50px; } but the window insists on cliping the image, and if I draw the image separately from the window the window puts itself on top of the image and there seems to be no way of preventing this.

I would prefer to be able to do GUI.DrawTexture(new Rect(-50, 0, 100, 100), img) inside the DrawWindow function. Is there any way of doing this?

I just played a bit with the window GUIStyle settings. Actually it's possible to achieve this but it involves some tricks. I used a GUILayout window. You are right, there's no way to draw GUI elements in a way that they "overflow" the containing window. But it's possible to do the opposite. You have to define your window large enough to include the whole image. You have to adjust the overflow property of your window style. When using negative values the backgound image of the window is getting smaller and the containing controls "look like" they are outside the window.

The tricky part is to calculate the right values for overflow. If you use a GUILayout window you can use GUILayoutUtility.GetLastRect to get the rectangle of the last placed control. Watch out, GetLastRect doesn't work in EventType.Layout so check for EventType.Repaint.

It’s just a crazy idea that have come to my mind. It could work but i got no time to test it :wink:

Here’s an easy way to do it: Draw the window with GUIStyle.none (the window texture shows up invisible). Then draw a box with the same Rect as the window, but using the window GUIStyle. Now you can draw on top of the box and it looks like you’re drawing on top of the window.

windowRect = GUILayout.Window(0, windowRect, DoWindow, "", GUIStyle.none);    		
GUI.Box(windowRect,"Window Title", new GUIStyle("window"));
GUILayout.Button("This appears to be drawn on top of the window");

The window is still draggable and you can still draw things inside the window function too.