Hey guys, ive just started using the Necromancer GUI and i re-did all my buttons with it, how would i turn GUILayout.Button(" Exit", "ShortButton");
into a button?
for example when i click it, it runs the script Application.Quit();
Hey guys, ive just started using the Necromancer GUI and i re-did all my buttons with it, how would i turn GUILayout.Button(" Exit", "ShortButton");
into a button?
for example when i click it, it runs the script Application.Quit();
GUILayout.Button(" Exit", "ShortButton')
{
//Do my action when clicked
Application.Quit();
}
i tried doing that, it keeps coming up with errors saying stuff like expecting : instead of ; after the Application.Quit() and when i do it it says
this is my whole code for that part
function DoExit (windowID : int)
{
GUILayout.BeginVertical();
GUILayout.Button(" Exit", "ShortButton");
{
//Do my action when clicked
Application.Quit():
}
GUILayout.EndVertical();
GUI.DragWindow (Rect (0,0,10000,10000));
}
The correct way of executing a piece of code on click of a button is as below:
if ( GUILayout.Button( Rect (0,0,50,20), "Exit" ) )
{
//Do my action when clicked
Application.Quit():
}
No he using GUILayout… Not GUI… which would then want a Rect position… GUI != GUILayout
As for afro kid… Take off the Semi colon…
function DoExit (windowID : int)
{
GUILayout.BeginVertical();
GUILayout.Button(" Exit", "ShortButton") // <-- No SemiColon
{
//Do my action when clicked
Application.Quit():
}
GUILayout.EndVertical();
GUI.DragWindow (Rect (0,0,10000,10000));
}