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
0
Question by Jackpoz · Jul 09, 2010 at 02:49 PM · arrayiphonelistexceptionmono

Using List.Count on Unity iPhone

this is a little piece of code that works like a charm in the Unity iPhone Editor but doesn't work on the iPhone, throwing an exception in the XCode console at runtime.

GameObject[] gos = GameObject.FindGameObjectsWithTag("TagUsedIngame");
//gos size is 4 in my test
List<GameObject> gosList = new List<GameObject>(gos);//<-- exception

the exception is documented at http://monotouch.net/Documentation/Troubleshoot

System.ExecutionEngineException: Attempting to JIT compile method (wrapper managed-to-managed) Foo[]:System.Collections.Generic.ICollection`1.get_Count () they suggest to write something like

Foo [] array = null;  
int count = ((ICollection<Foo>) array).Count;

which is pretty funny since this code will throw a null deref exception^^

did anyone already solve this issue? It's more related to Mono than to Unity, because it works fine in the Editor. I set .NET in the Player Settings of the Project to 2.1 . Thank you for the time spent reading this wall of text.

Comment
Add comment · Show 1
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 Fattie · Dec 26, 2011 at 11:54 PM 0
Share

FYI Note this $$anonymous$$UCH NEWER answer from 2011

http://answers.unity3d.com/questions/54841/does-current-iphone-support-listt-in-c.html

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Molix · Jul 09, 2010 at 03:03 PM

I believe generics (System.Collections.Generic) are not fully supported on iPhone.

There are some good suggestions and details in this Q&A

Comment
Add comment · Show 2 · 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 Jackpoz · Jul 09, 2010 at 03:20 PM 0
Share

more like they are not supported at all, if i can't even get the Count of elements...

avatar image Jackpoz · Jul 09, 2010 at 03:48 PM 0
Share

indeed, had to use an ArrayList....

avatar image
1

Answer by Tetrad · Jul 09, 2010 at 04:02 PM

Don't construct a List with an array, it crashes on the phone. Known bug.

Instead add the objects one at a time.

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 Jackpoz · Jul 11, 2010 at 09:51 AM 1
Share

i hackfixed it using the non-generic ArrayList type. ArrayList gos = new ArrayList(GameObject.FindGameObjectsWithTag(tag));

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

1 Person is following this question.

avatar image

Related Questions

Why does List .ToArray throw ArgumentException? 1 Answer

A node in a childnode? 1 Answer

How to prevent picking the same combination in array? 1 Answer

PrefabHell - How to have scripts of prefabs instances reference the variables of the prefab instance they're attached to? 1 Answer

Accesing custom class object from another script 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