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 benjaben · Dec 17, 2011 at 02:55 PM · lists

Managing a large list of objects

I am using the List class to store a large amount of nodes for my pathfinding grid. However if I try to go above about 7,500 objects in the List Unity almost completely freezes up. Would there be a more efficient way to keep track of this many objects?

Comment
Add comment · Show 3
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 Eric5h5 · Dec 17, 2011 at 03:36 PM 0
Share

7500 isn't that many; I guess the issue is with what you're doing exactly.

avatar image benjaben · Dec 17, 2011 at 04:21 PM 0
Share

I have Node objects in the list. Each node object has a Node.cs script attached to them and thats it. I'm really not sure what it freezes so bad

avatar image flamy · Dec 17, 2011 at 08:34 PM 0
Share

most of the freezing problems in unity can be fixed by moveing the code tht freezes to a seperate thread!! it worked for me in most cases!!(unless it is a infinite loop!)

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Owen-Reynolds · Dec 17, 2011 at 08:45 PM

I'd guess that many gameObjects could be the problem, when you probably don't need them to be. Could make node be a regular class (no inherit from MonoBehavior) and create it the normal programming way:

 LinkedList<Node> N; 
 N = new LinkedList<Node>(7500);
 for(int i=0;i<7500;i++) {
   N[i] = new Node();
   // math to set node values from whatever
 }

If you actually have 7500 gameObjects, that people have hand-entered data into, you can still suck that into the Nodes at run-time and delete them.

Also, a List is good for fast anywhere inserts&deletes and OK for going from front to back. It's pretty awful for looking in spot i (for example, if Node 106 links to 390 and 5602.) For random access like that, an array is much faster.

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 benjaben · Dec 20, 2011 at 05:29 PM 0
Share

Thank you for your input. I'm so used to having everything GameObject based that just using program$$anonymous$$g seems strange haha.

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Lists, Arrays and c# equivilent of js Array() 1 Answer

Adding items to inventory with random values 1 Answer

UNITYSCRIPT - Class's and Instances - Functions/Methods - Correct Usage 0 Answers

Always adds items to list 1 Answer

Class lists not entirely working 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