Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 iikanev · Aug 25, 2017 at 03:51 PM · arrayloadingreference

Loading an element from an array without loading the whole array?

(I am developing on android) I have a big array which i rarely use but from time to time i need to load some data from it.The problem is that because of the array size the whole game freezes until the data loads. Is there a way to only get the array item that i need without loading the whole array first.

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 SuryaEU · Aug 25, 2017 at 06:48 PM 2
Share

Hello, $$anonymous$$aybe you could give more context: Where is this array co$$anonymous$$g from? Array is a pretty generic word: for me an array is already in the memory, so you wouldn't have to "load" it.

From your question I guess what you name "array" is a list of data from a file?

avatar image iikanev SuryaEU · Aug 25, 2017 at 09:14 PM 0
Share

well my code looks something like this:

 using UnityEngine;
 
 [System.Serializable]
 public class Item
 {
 
     public string name;
     public string belongingSet;
     public Texture2D image;
     public string rarity;
     public int price;
     public bool isLegacy;
 
 }


then i do something like this

 public Item[] itemList = new Item[]

I need to access a random item in the array but if i reference the script on a gameobject the scene takes considerably longer to load. So my question is.. is there any way i can access the array without making a reference of it inside another script.

avatar image FortisVenaliter iikanev · Aug 25, 2017 at 09:25 PM 0
Share

No, there definitely isn't a way to reference it without loading it. Not unless you wrote it to a file, then wrote a table of contents with the byte indices of each item. Then you could load it specifically, but you're adding file and disk operations which would easily destroy any net benefit.

But, more to the point, I don't see anything in the code you've posted that would cause a long load time. Can you post the code showing how you instantiate each Item instance? A small performance boost in a big loop can bring big gains.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by $$anonymous$$ · Aug 26, 2017 at 12:16 AM

You could use a B-Tree, unfortunatelly unity doesn't have a library for this by default but there are resources out there that can do the job. I haven't personally tried these but a google search came up with this: https://www.assetstore.unity3d.com/en/#!/content/21652 https://github.com/psychobolt/unity-btree

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

78 People are following this question.

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

Related Questions

Reference scriptable object by path 0 Answers

(Yet another) Accessing array in another script - ref or copy? 1 Answer

Why does gameobject.Find/GetComponent not work when a new scene is loaded? 1 Answer

Saving and loading array (/list) of integers locally 1 Answer

Temporary textures or Materials in Editor removed in build 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