|
I have a large unity3d javascript script I am trying to run on iphone. I'm getting tons of errors about variables not having their types defined. If I put # pragma strict at the top of the script it shows the errors in the unity compiler console. My question is do I have to redefine all these using var? Or is there some shortcut setting that I can use to bypass all the errors? What about arrays? Right now I have javascript Arrays like myarray=new Array(); Should I just use something like myarray=Vector3[]; I have an array full of rotations. What kind of array is that? Quaternions, Vector4? I use lots of hashtables how do I define ahead of time what's going in those? What about functions? Some functions complain others do not. Do I define the arguments in the function declaration? function myfunction(a:int,b:int); Is there any documentation that says everything you have to do to go from javascript to iphone? -- things like eval() does not work, or that you have to define every variable etc... use built in arrays, etc... Thanks,
(comments are locked)
|
|
Never use Array, never use Hashtable. If you have a fixed-size array, use int[], Vector3[], etc. (As for rotations, look in the docs, it always tells you the type of everything.) If you have a variable-sized array, use List. Use Dictionary instead of Hashtable. And yes, you must always define the types in a function declaration. Yeah forgot to mention that as well. As far as i knew you always had to define the types and return types for functions, how is it possible to not do so?
Feb 27 '12 at 01:26 AM
Default117
Dictionary and List are .net functions? is that correct, not unity?
Feb 27 '12 at 01:30 AM
dansav
You don't have to define types if the compiler can infer it from the value supplied. The type doesn't change at runtime so it's not dynamic typing. What you should not do is this, because the type can't be inferred: Instead, Dictionary and List are .net, yes. It's the same as C# except for the extra "."
Feb 27 '12 at 01:37 AM
Eric5h5
Thanks now I get it completely. I have a ton of work todo. The combined total of these comments would make a great addition to the unity docs for all the javascript coders.
Feb 27 '12 at 01:50 AM
dansav
(comments are locked)
|
|
Have a read of this document: http://unity3d.com/support/documentation/Manual/iphone-GettingStarted.html By default iOS turns of dynamic casting, which essentially would do the same thing when you do #pragma strict. You just need to ensure that you declare all your variable data type, which you really should be doing anyway, its just good practice. and so forth
(comments are locked)
|

How would I do an array of hashtables on iphone? animations=new Array(); animations[0]=new Hashtable();