Hello, I was wondering if you can click a GUI.Button and a Window pops up and then you can drag the window or you can have the window in one place.
Is there anybody that can help me out.
Thankyou
Chris
Hello, I was wondering if you can click a GUI.Button and a Window pops up and then you can drag the window or you can have the window in one place.
Is there anybody that can help me out.
Thankyou
Chris
It’s pretty easy, just look at the examples, and try it. If you still need help, then feel free to ask. ![]()
Hey, I still having problems. I done this up to now and when I click chat the window does not appear.
/* GUI.Toolbar example */
var newSkin : GUISkin;
var windowRect0 : Rect = Rect (20, 20, 120, 50);
var windowRect1 : Rect = Rect (20, 100, 120, 50);
function OnGUI () {
GUI.skin = newSkin;
GUI.Button (Rect (485, 50, 115, 30), “Chat”);
}
function OnMouseDown()
{
// Here we make 2 windows. We set the GUI.color value to something before each.
GUI.color = Color.red;
windowRect0 = GUI.Window (0, windowRect0, DoMyWindow, “Red Window”);
}
// Make the contents of the window.
// The value of GUI.color is set to what it was when the window
// was created in the code above.
function DoMyWindow (windowID : int) {
if (GUI.Button (Rect (10,20,100,20), “Hello World”))
print ("Got a click in window with color " + GUI.color);
// Make the windows be draggable.
GUI.DragWindow (Rect (0,0,10000,10000));
}
thankyou
chris
if(GUI.Button (Rect (485, 50, 115, 30), "Chat"))
{
mycode here, use a boolean switch to pop a window
}
Hey, I tried it and it does not seem to work.
Hey, the script you gave me appels does not work.
var newSkin : GUISkin;
var myBoolean = false;
function OnGUI ()
{
GUI.skin = newSkin;
if(GUI.Button(Rect(485,50,115,30), “show wondow”))
{
if(myBoolean = false)
myBoolean = true;
else
myBoolean = false;
}
if(myBoolean)
windowRect = GUI.Window (0, windowRect, DoMyWindow, “My Window”);
}
function DoMyWindow (windowID : int) {
if (GUI.Button (Rect (10,20,100,20), “Hello World”))
print (“Got a click”);
}
These are the errors
1)Assets/aToolBar Scripts/Chatbox.js(9,14): BCE0044: expecting ), found ‘=’.
2)Assets/aToolBar Scripts/Chatbox.js(9,16): BCE0043: Unexpected token: false.
3)Assets/aToolBar Scripts/Chatbox.js(11,1): BCE0044: expecting }, found ‘else’.
4)Assets/aToolBar Scripts/Chatbox.js(16,1): BCE0044: expecting EOF, found ‘}’.
Thankyou
Chris
var newSkin : GUISkin;
var myBoolean = false;
var windowRect : Rect = Rect (20, 20, 120, 50);
function OnGUI ()
{
GUI.skin = newSkin;
if(GUI.Button(Rect(485,50,115,30), "show window"))
{
if(myBoolean == false)
myBoolean = true;
else
myBoolean = false;
}
if(myBoolean)
windowRect = GUI.Window (0, windowRect, DoMyWindow, "My Window");
}
function DoMyWindow (windowID : int) {
if (GUI.Button (Rect (10,20,100,20), "Hello World"))
print ("Got a click");
}
Why, wont it let me change the height and width. Also the position it pops up at.
However, thankyou it works now.
thankyou
chris
where are you changing the width and height ?
I am changing here —> var windowRect : Rect = Rect (20, 20, 120, 50);
the inspector values have priority over the scripted ones
just some friendly advice … before you offer your help in a thread with title ‘Need a Gui specialist’, become one first… then offer your services.
I got it to work, I just set the —> var windowRect : Rect = Rect (20, 20, 120, 50); —> to private var windowRect : Rect = Rect (20, 20, 120, 50);