- Home /
GUI button's disappearing behind full screen Texture
hey guy and gals! im working on a main menu screen. pretty simple, i have a full screen texture script and a load level script but heres the rub, when i play the game the GUI button textures appear behind the full screen texture. now if i unclick the check box by the full screen texture script i can see the buttons and if i click it again the buttons appear correctly above the full screen texture. i've tried rebuilding the scene a couple of times and heres the weird part, at first it will all display correctly then it'll go back to being hidden.
i thought maybe it was an order issue kinda like layers over lapping in photoshop but i've moved them into different orders and i get the same issue. both the scripts are applied to a empty Gameobject.
below are the two scripts im using in case its a scripting error.
here is the script for my load level button
var levelToLoad:String;
var graphic = TextureGUI(); //(28,23);
var startPoint = Location();
var GUIColor:Color = Color.white;
var noGuiStyle : GUIStyle;
function Start() {
graphic.setAnchor();
}
function Update() {
if (graphic.texture){
startPoint.updateLocation();
}
}
function OnGUI() {
GUI.color = GUIColor;
if (GUI.Button(Rect(graphic.offset.x+startPoint.offset.x,graphic.offset.y+startPoint.offset.y,graphic.texture.width,graphic.texture.height),graphic.texture,noGuiStyle)) {
Application.LoadLevel("test_tunnel");
}
}
and here is the display full screen script
@script ExecuteInEditMode()
var graphic = TextureGUI(); //(28,23);
var GUIColor:Color;
function OnGUI() {
GUI.color = GUIColor;
if (graphic.texture) {
GUI.DrawTexture(Rect(graphic.offset.x,graphic.offset.y,
Screen.width,Screen.height),
graphic.texture,ScaleMode.StretchToFill,true);
}
}
function AlphaUp(change:float) {
GUIColor.a += change;
}
function setStartColor(color:Color) {
GUIColor = color;
}
function setDelay(delay:float) {
if (GUIColor.a > .5) {
GUIColor.a += delay;
} else {
GUIColor.a -= delay;
}
}
function AlphaDown(change:float) {
GUIColor.a -= change;
}
thanks for any help you guys can give me!
-Mike
Answer by Seth-Bergman · Mar 12, 2013 at 10:16 PM
for this simply use GUI.depth
just add :
GUI.depth = -1;
to the button script (inside the GUI function), problem solved!
you sir are a genius! it now works like a charm! thanks for the quick response time as well!