Hi at all,
I am tried to compile my project with #pragma strict header, but I meet a lot of error like this:
Hi at all,
I am tried to compile my project with #pragma strict header, but I meet a lot of error like this:
You might find it easier to use built-in arrays for this:-
var a: int[] = int[5];
The type is explicitly declared so there are no conversion problems.
I cannot beceause I don’t know the number of elements which I need to store in.
Exists Generics inside Unity 3 JS ?
Like this :
In the worst case, you may have to convert it to a builtin before looping the content.
var tempArray : int [ ] = array.ToBuiltin ();
Yes, as of Unity 3, you can use generics in UnityScript.
I doubt that would compile with pragma strict; wouldn’t ToBuiltin() return object[ ]?
#pragma strict
//~ #pragma downcast
private var listArray : Array = new Array ();
private var listBuiltin : int [];
function Start ()
{
listBuiltin = listArray.ToBuiltin (int);
}
Look like #pragma downcast is required, I can’t see how to do without it.
: - (
Uff!
Source : http://www.unifycommunity.com/wiki/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use%3F
That’s obsolete now that Unity 3 is out.
–Eric
Hello
I am having the same problem. Were you able to solve it pedr0 ?
How, exactly? Searching for “unityscript generics” yields no usable results, and using C#'s Array syntax gives a syntax error.