|
if i put these lines of code in the script:
i get this error: Unexpected Token: .. i wanted to start using lists instead of arrays but no luck... it seems that most simplest thing is not working, like declaring a list...i am using unityscript as you can see.... thanks! cross post in unity forums: http://forum.unity3d.com/threads/80203-can-someone-explain-to-me-why-this-does-not-work
(comments are locked)
|
|
You need Unity 3 to be able to use generics in js/unityscript 2.6 will just throw errors at you ohhh...i was not aware of this :(
Mar 02 '11 at 02:38 PM
pretender
but wait, i am using unityscript
Mar 02 '11 at 02:41 PM
pretender
uh, typo - fixing (it should be js, not c# - 2.6 has generics for c#just fine)
Mar 02 '11 at 02:45 PM
Mike 3
damn...so i am stuck with arrays??
Mar 02 '11 at 02:58 PM
pretender
You could use ArrayList (which acts like List
Mar 02 '11 at 03:03 PM
Mike 3
(comments are locked)
|
|
">= " is interpreted as greater than or equal to. Use nicer spacing; pixels are plentiful on modern monitors. ;-)
Also, it's JS, so you don't need new if you don't want, and you don't need to declare the type, either. i tried this and it did not work. both thing you suggested, still getting the "Unexpected Token : .." the line error appear is this var boxColliderList : List. = new List.(); it is strange to be honest... also sorry about cross linking..
Mar 02 '11 at 12:58 PM
pretender
Didn't work for me; the space is required on my system.
Mar 02 '11 at 01:36 PM
Jessy
The space is a problem for me, but It's not the same problem the OP has. Also, I wouldn't go around advising people not to type their variable declarations unless it's really necessary.
Mar 02 '11 at 02:27 PM
burnumd
burnumd, that's not dynamic typing. You can use the exact same code in C#, even, with only the dot left out. http://stackoverflow.com/questions/41479
Mar 02 '11 at 02:43 PM
Jessy
Just removed my useless comments since it turned out that Jessy's answer is 100% right.
Mar 02 '11 at 03:11 PM
Bunny83
(comments are locked)
|

In what line / column do you get this error? import should be used at the top of your script. Don't use it inside a function or class.
The List<> works even without the import (at least for me...)
-1 for posting on the forum too, and not cross-linking. http://forum.unity3d.com/threads/80203
I have a little test script with exactly the same code and it works without any errors. Maybe there's something wrong after this two lines? Or even before? Another general programming hint: if you call your variable boxColliderList it should contain BoxColliders. If you want to store different colliders, the variable should be called just colliderList. The variable name should represent it's usage
yes it is meant to hold boxColliders...i changed the name of the variable and it did not make any change. still getting the error. also i tried what jessy proposed, that did not work... i do not know what is going on. this part of code is at the top of the script.