- Home /
GUI Window remove white border from active window
Well, the title pretty much says it. How do I remove that annoying white border from the focused window in GUI.Window()?
I tried calling GUI.UnfocusWindows(), but that seems to mess lots of things up.
Yes it's annoying. Other trying to unfocus (which I've not had any success with), you can modify the GUI style so that it there isn't an onHover and onFocus graphic.
Now the reason this isn't in the answer column is although it ought to work I personally cannot get it working. I am totally confident that this the right approach I just can't seem to do it right.
Here is my post on the topic. http://answers.unity3d.com/questions/240382/problems-controlling-the-gui-skin-style.html
If you work out exactly how to clone the skin or modify the built in GUI skin so the style behaves correctly please post the code here and put me out of my misery.
What worked for me was (for whatever reason) GUIStyle.onNormal. I posted on your thread as well
Yes, I tried but as I said it didnt work. What you suggested makes total sense its probably just a coding error on my part. What does you code look like?
Answer by Lttldude · Apr 21, 2012 at 03:14 PM
I think I may have a solution. Correct me if I misunderstand the problem.
1) download and import the builtin GUI skin package
2) Create a new GUISkin
3) In the new skin, change the onNormal background for the window to the "window" texture under the imported assets (BuiltIn Skin/Sources/). This will make the onfocus window look like the unfocused window.
4) add skin to script:
var windowFixSkin : GUISkin;
function OnGUI()
{
//change the GUI Skin
GUI.skin = windowFixSkin;
//[THE GUI WINDOW]
//change the GUI skin back to what it was, or to default with null value
GUI.skin = null;
}
Hope this helps. Good luck.
Answer by Fabkins · Apr 21, 2012 at 03:20 PM
Ok, I messed about for 10 mins until I worked out which it was. Here this will do what you need:
GUI.skin.GetStyle("Button").onActive.background=GUI.skin.GetStyle("Button").onNormal.background;
GUI.skin.GetStyle("Button").active.background=GUI.skin.GetStyle("Button").normal.background;
GUI.skin.GetStyle("Button").hover.background=GUI.skin.GetStyle("Button").normal.background;
GUI.skin.GetStyle("Button").onHover.background=GUI.skin.GetStyle("Button").normal.background;
This gets rid of the white border on all conditions I can find.
Yeah, that's pretty much exactly what I did, ha! I said that in my post to your thread (whenever it shows up), I just didn't notice those four members doing anything for GUI.Window.
It is apparently different for GUI.Button, as GUIStyle.onNormal doesn't seem to affect anything there. Thanks for the help!
Answer by slippdouglas · Mar 21, 2014 at 08:01 AM
Sanest, simplest solution I've been able to work out:
In the class that wishes to draw the non-bordered window:
static GUIStyle _NonSelectableWindowStyle;
static GUIStyle NonSelectableWindowStyle {
get {
if (_NonSelectableWindowStyle == null) {
GUIStyle s = new GUIStyle(GUI.skin.window);
s.onNormal.background = null;
_NonSelectableWindowStyle = s;
}
return _NonSelectableWindowStyle;
}
}
And then the GUI
/GUILayout.Window
call:
void OnGUI()
{
GUILayout.Window(
id: this.windowID,
screenRect: this.menuRect,
func: DrawMenuContents,
text: this.menuTitle,
style: NonSelectableWindowStyle, // <-- notice!
GUILayout.Width(MenuWindowWidth), GUILayout.ExpandHeight(true)
);
}
Good C# coding practices included just because I love you all. And I'm a little drunk.
Your answer

Follow this Question
Related Questions
ArgumentException: Getting control 0's position in a group with only 0 controls when doing Repaint 0 Answers
How will i get new line in window data? 1 Answer
GUI.Window error. InvalidOperationException: Hashtable.Enumerator: snapshot out of sync. 0 Answers
Are dockable windows possible in-game. 2 Answers
Close (X) button 1 Answer