var Button1:Texture;
var Button2:Texture;
var Button3:Texture;
var Button4:Texture;
var myskin:GUISkin;
function OnGUI () {
GUI.skin=myskin; }
if (GUI.Button (Rect ((Screen.width/2)-(Button1.width/2)-10,(Screen.height/2)-(Button1.height/2),300,200),Button1));
{
Application.LoadLevel ("Game"),
}
if (GUI.Button (Rect ((Screen.width/4)*3-(Button2.width/2)+140,(Screen.height/2)-(Button2.height/2),200,150),Button2)) {
Debug.Log("Button 2 Pressed");
}
if (GUI.Button (Rect ((Screen.width/4)*1-(Button3.width/2)-60,(Screen.height/2)-(Button3.height/2),200,150),Button3)) {
Debug.Log("Button 3 Pressed");
}
}
function Update () {
}
Never saw that many errors at once:
- All GUI stuff have to be inside the OnGUI. I guess the bracket after `GUI.skin=myskin;` is wrong.
- The first button is terminated with a ";". That way the following code is not related to the if statement
- The error you get says "expecting ; found ,". After your `Application.LoadLevel` you have a ","(comma) but you need a ";"(semicolon)
- If you don't need the Update function, remove it because it drains performance even when it's empty.
- Pick one indent style and keep it.
- If you post code here make sure you mark it as "code". There's a button at the top of the edit field (10101). See the Editing-help for more information.
Here's the corrected script:
var Button1:Texture;
var Button2:Texture;
var Button3:Texture;
var Button4:Texture;
var myskin:GUISkin;
function OnGUI () {
GUI.skin=myskin;
if (GUI.Button (Rect ((Screen.width/2)-(Button1.width/2)-10,(Screen.height/2)-(Button1.height/2),300,200),Button1)) {
Application.LoadLevel ("Game");
}
if (GUI.Button (Rect ((Screen.width/4)*3-(Button2.width/2)+140,(Screen.height/2)-(Button2.height/2),200,150),Button2)) {
Debug.Log("Button 2 Pressed");
}
if (GUI.Button (Rect ((Screen.width/4)*1-(Button3.width/2)-60,(Screen.height/2)-(Button3.height/2),200,150),Button3)) {
Debug.Log("Button 3 Pressed");
}
}
Try this:
var Button1:Texture;
var Button2:Texture; var Button3:Texture; var Button4:Texture;
var myskin:GUISkin;
function OnGUI () { GUI.skin=myskin; }
if (GUI.Button (Rect ((Screen.width/2)-(Button1.width/2)-10,(Screen.height/2)-(Button1.height/2),300,200),Button1)){
Application.LoadLevel("Game");
if (GUI.Button (Rect ((Screen.width/4)*3-(Button2.width/2)+140,(Screen.height/2)-(Button2.height/2),200,150),Button2)) {
Debug.Log("Button 2 Pressed");
}
if (GUI.Button (Rect ((Screen.width/4)*1-(Button3.width/2)-60,(Screen.height/2)-(Button3.height/2),200,150),Button3)) {
Debug.Log("Button 3 Pressed");
}
}
function Update () { }