Forums

ForumsProgramming Forum

Unity help (javascript)

Posted Sep 8, '11 at 6:06am

crazyhman

crazyhman

45 posts

I have two errors:

1. Assets/StartMenuGUI.js(8,9): BCE0044: expecting }, found 'private'.

2.Assets/StartMenuGUI.js(45,1): BCE0044: expecting EOF, found '}'.


// Make the script also execute in edit mode
@script ExecuteInEditMode()

function Update () {

var gSkin : GUISkin;
var backdrop : Texture2D; // our backdrop image goes in here.
private var isLoading = false; // if true, we'll display the "Loading..." message.

function OnGUI()
{
if (gSkin)
GUI.skin = gSkin;
else
Debug.Log("StartMenuGUI: GUI Skin object missing!");

var backgroundStyle : GUIStyle = new GUIStyle();
backgroundStyle.normal.background = backdrop;
GUI.Label ( Rect( (Screen.width - (Screen.height * 2)) * 0.75, 0, Screen.height * 2,
Screen.height), "", backgroundStyle);

GUI.Label ( Rect( (Screen.width/2)-197, 50, 400, 100), "Lerpz Escapes",
"mainMenuTitle");

if (GUI.Button( Rect( (Screen.width/2)-70, Screen.height - 160, 140, 70), "Play"))
{
isLoading = true;
Application.LoadLevel("TheGame"); // load the game level.
}

var isWebPlayer = (Application.platform == RuntimePlatform.OSXWebPlayer ||
Application.platform == RuntimePlatform.WindowsWebPlayer);
if (!isWebPlayer)
{
if (GUI.Button( Rect( (Screen.width/2)-70, Screen.height - 80, 140, 70), "Quit"))
Application.Quit();
}

if (isLoading)
GUI.Label ( Rect( (Screen.width/2)-110, (Screen.height / 2) - 60, 400, 70),
"Loading...", "mainMenuTitle");
}


}

 

Posted Sep 8, '11 at 12:40pm

WhiskeyedJack

WhiskeyedJack

85 posts

You don't define private variables using the prefix private, that's probably what's breaking for you

 

Posted Sep 8, '11 at 12:44pm

WhiskeyedJack

WhiskeyedJack

85 posts

Also, did you mean to define function OnGUI() inside of function Update() ?

 

Posted Sep 9, '11 at 7:18pm

crazyhman

crazyhman

45 posts

All should work except for those BCE0044 errors. I believe OnGUI() is supposed to be outside but I will try inside just in case.

 

Posted Sep 9, '11 at 7:23pm

crazyhman

crazyhman

45 posts

The OnGUI() is supposed to be inside, when I tried it outside it came up with about 10 more errors

 

Posted Sep 10, '11 at 5:07pm

WhiskeyedJack

WhiskeyedJack

85 posts

like I said before,

private var isLoading = false;

won't work. You will have to remove the word private.
 

Posted Sep 10, '11 at 5:16pm

WhiskeyedJack

WhiskeyedJack

85 posts

Although unity may actually interpret javascript slightly differently... So ignore my previous statement. Sorry, I haven't actually worked with unity3d at all.

Try this post, they seemed to have a similar problem and it was due to the fact that they were declaring one function within another. Sorry I couldn't help more.

 
Reply to Unity help (javascript)

You must be logged in to post a reply!