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
3
Question by Dravel · Jan 21, 2011 at 10:05 PM · sortbuiltin array

Builtin Clarifications

I'm using builtin arrays for a lot of ai stuff like prioritizing actions and keeping track of known objects, etc.

When I first started using Unity I was told that while the builtin arrays are very fast they lack the functionality of other array types.

Right now I'm pretty exclusively using builtin arrays, even for things like sorting, paired sorting, and binary searches, etc.

The language i'm using for these functions is stuff like System.Array.Sort(builtin), or System.Array.BinarySearch(builtin, object)

What I wanted to know is whether I'm taking advantage of the speed of the builtin arrays, or whether what I'm really doing is instantiating new mono arrays, performing the functions, and then converting the result back to the builtin array (when the array is altered by said function, rather than just having it return an int or whatever), and if that's the case whether it's lighter on the performance cost to iterate through the builtin arrays myself with for loops and such.

I'm not much of a programmer, just really been tooling around unity in my spare time, so I was hoping that someone here might help clarify the issue.

Thanks,

Dravel

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by yoyo · Aug 14, 2014 at 05:59 AM

A Mono array and a built-in array are the same thing -- an instance of System.Array. There is only a difference in javascript, which has its own arrays -- these are less efficient. The main drawback of a built-in array is that once allocated it cannot be resized. You can allocate a new, larger (or smaller) array and copy the original array, but you cannot resize the original array directly. Searching and sorting should be efficient, though if you need to keep re-sorting an array you might be better off with data structures like Dictionary or SortedList, which are only available from C#, not javascript.

More information can be found in the Array documentation.

Comment
Add comment · 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

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

Sorting builtin arrays 2 Answers

switch between multiple cameras based on distance to target 2 Answers

How do I sort Game Objects from closest to furthest, by tags? 1 Answer

Dynamic Turn Order and Display Based On Initiative Value (Javascript)? 2 Answers

sorting list of key, value by value 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