- Home /
Button in front of GUI Window
Hello everyone,
Basically, I have a scrollview of windows, and I'd like to have a main button in front of it.
But I'm unable to achieve this. I tried with GUI.BringWindowToBack, GUI.depth and even try to create the button from another script but nothing seems to work.
Does anyone ever achieve to do this?
Thanks in advance
Windows float above normal GUI controls
from the script reference
are you wanting a button inside of your window?
Not really, I need a button in front of all my windows
As I quoted above, I dont believe you can get a normal GUI Button in front of a window without it being placed inside the window.
Yeah that what I found around the net too. But it seems so obvious that many people have tried to do it, that's why I was asking if nobody have found a hack or an alternative solution
Answer by tw1st3d · Aug 01, 2013 at 04:37 PM
using UnityEngine;
using System.Collections;
public class Menu : MonoBehavior
{
void OnGUI()
{
GUI.Box();
// Make a GUI Box,
// No values for time saving
GUI.Box();
// Let's make another one
GUI.Button();
// NOW create the button
}
}
create the button after everything else
Thanks for the reply but i'm talking about GUI.Window, not Box.
It should work exactly the same, however if I'm mistaken, sorry.
Not really, GUI.Window are created in a weird way which make the placement of the button at the end useless.
Answer by Seizure · Aug 01, 2013 at 04:38 PM
Yes I am able to do it, much like you did, with GUI.bringWindowToBack and GUI.Depth. One of the things I am probably doing different though is that my button is in a seperate script from my window. Try setting the window to a lower GUI.Depth and sending it to the back in a seperate script.
First Script:
GUI.depth = -20;
scrollPosition = GUI.BeginScrollView (rScrollFrame, scrollPosition, rList, false, false);
for ( var k : int = 0; k < numRows; k++)
{
GUI.Window (k, Rect(0,Screen.height/10-scrollPosition.y + (k*200),Screen.width-30,200), GUI.WindowFunction (testW), "");
}
GUI.EndScrollView();
second script:
GUI.depth = 20;
if( GUI.Button(Rect(0,0, Screen.width, Screen.height/10), ""))
{
//nothing
}
But not working at all!
Your answer
Follow this Question
Related Questions
Dragging and Locking Buttons. 1 Answer
Stop clicking through a GUI window 2 Answers
Buttons in window problem 2 Answers
Open window on button click 1 Answer