Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by pretender · Mar 02, 2011 at 11:35 AM · errorlistsdeclaration

why this does not work (Lists)

if i put these lines of code in the script:

import System.Collections.Generic;
var boxColliderList : List.<Collider>=new List.<Collider>();

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

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Mar 02, 2011 at 12:46 PM 0
Share

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.

avatar image Bunny83 · Mar 02, 2011 at 12:48 PM 0
Share

The List works even without the import (at least for me...)

avatar image Jessy · Mar 02, 2011 at 12:51 PM 1
Share
  • for posting on the forum too, and not cross-linking. http://forum.unity3d.com/threads/80203

avatar image Bunny83 · Mar 02, 2011 at 01:13 PM 0
Share

I have a little test script with exactly the same code and it works without any errors. $$anonymous$$aybe there's something wrong after this two lines? Or even before? Another general program$$anonymous$$g 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

avatar image pretender · Mar 02, 2011 at 01:15 PM 0
Share

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.

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Jessy · Mar 02, 2011 at 12:43 PM

">= " is interpreted as greater than or equal to. Use nicer spacing; pixels are plentiful on modern monitors. ;-)

var boxColliderList : List.<Collider> = new List.<Collider>();

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.

var boxColliderList = List.<Collider>();
Comment
Add comment · Show 10 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pretender · Mar 02, 2011 at 12:58 PM 0
Share

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..

avatar image Jessy · Mar 02, 2011 at 01:36 PM 0
Share

Didn't work for me; the space is required on my system.

avatar image burnumd · Mar 02, 2011 at 02:27 PM 0
Share

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.

avatar image Jessy · Mar 02, 2011 at 02:43 PM 0
Share

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

avatar image Bunny83 · Mar 02, 2011 at 03:11 PM 0
Share

Just removed my useless comments since it turned out that Jessy's answer is 100% right.

Show more comments
avatar image
1

Answer by Mike 3 · Mar 02, 2011 at 02:22 PM

You need Unity 3 to be able to use generics in js/unityscript

2.6 will just throw errors at you

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pretender · Mar 02, 2011 at 02:38 PM 0
Share

ohhh...i was not aware of this :(

avatar image pretender · Mar 02, 2011 at 02:41 PM 0
Share

but wait, i am using unityscript

avatar image Mike 3 · Mar 02, 2011 at 02:45 PM 1
Share

uh, typo - fixing (it should be js, not c# - 2.6 has generics for c#just fine)

avatar image pretender · Mar 02, 2011 at 02:58 PM 0
Share

damn...so i am stuck with arrays??

avatar image Mike 3 · Mar 02, 2011 at 03:03 PM 0
Share

You could use ArrayList (which acts like List), but that's about it unfortunately

avatar image
0

Answer by SpookyCat · Mar 02, 2011 at 01:47 PM

You have a '.' between List and < ie List.< should be List<

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SpookyCat · Mar 02, 2011 at 01:48 PM 1
Share

ok ignore that, using UnityScript I see

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Scripting error! 1 Answer

How to enable a ParticleEmitter in scripting 2 Answers

Unknown Identifier 'List' 1 Answer

Errors in Vector2 variables 1 Answer

IComparable error due to float 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges