- Home /
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?
Answer by Bunny83 · Oct 13, 2011 at 12:43 AM
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.
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.
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...
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 my$$anonymous$$esh = new $$anonymous$$esh(); // type will be "$$anonymous$$esh"
Ah, thanks, that helps heaps. I don't think I'll use strict though :D
NV$$anonymous$$, just read: "The benefits are improved error checking and more efficient code generation leading to faster execution times"
Your answer
Follow this Question
Related Questions
Multiplayer Problems 1 Answer
Please, help me translating these to C# 1 Answer
How to retrieve current stock market prices? 2 Answers