x


Networking Example has lots of errors in Unity 3.4

Normally I'm quite good at fixing errors myself, but these ones are just too strange. All of these errors are Unknown Identifier errors. Did something in the JS scripting engine change recently? I think I last used the example in Unity 3.0 and it worked then.

I'm getting lots of errors that don't make sense, like:

for(i=0;i<4;i++)

Unknown Identifier: i

Is my MonoDevelop corrupted?

more ▼

asked Oct 13 '11 at 12:35 AM

YM_Industries gravatar image

YM_Industries
134 3 4 7

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

If you referring to a special example project it would help to include a link to it or at least post a bit more code and even more important the name or extention of the script file.

The first line "could" compile without the strict pragma but i'm not sure, i don't use UnityScript. However if this script is writting in Unityscript just add the var keyword like this:

for(var i = 0; i < 4; i++)

The second line is clearly C# and not UnityScript (Javascript). Are those two lines from the same script? What's the complete error?

As i've mentioned several times on other questions always include also the code before the error. Semicolon errors usually comes from a missing bracket or something like that.

more ▼

answered Oct 13 '11 at 12:43 AM

Bunny83 gravatar image

Bunny83
45.2k 11 49 207

Both errors are from the same script, but the second error was on a line I wrote while trying to fix the error. I am used to C#, not JS but thought variable declarations were the same. (From looking at the rest of the script) Adding var before the i worked! Thanks. There are a few other errors that I will try to solve now.

Oct 13 '11 at 12:48 AM YM_Industries

Just changed it to no longer be strict and all my errors went away. Has something changed in the strictness? Because that code used to work...

Oct 13 '11 at 12:49 AM YM_Industries

Yep, as far as i remember they made some more things strict, but as i said i don't use UnityScript so i can't really tell ;)

Variable declarations looks different than in C#:

// Dynamically typed var (very slow due to needed typecasting)
var myVar;

// statically typed var
var myVar : int;
var myVar : GameObject;

// also statically typed due to type-inference
var myVar = 5;  // type will be "int"
var myMesh = new Mesh(); // type will be "Mesh"
Oct 13 '11 at 01:08 AM Bunny83

Ah, thanks, that helps heaps. I don't think I'll use strict though :D

Oct 13 '11 at 01:12 AM YM_Industries

NVM, just read: "The benefits are improved error checking and more efficient code generation leading to faster execution times"

Oct 13 '11 at 01:27 AM YM_Industries
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3455
x702
x7

asked: Oct 13 '11 at 12:35 AM

Seen: 985 times

Last Updated: Oct 13 '11 at 01:27 AM