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 xiak · May 08, 2018 at 12:25 PM · resources.loadall

Loading a large number of image resources

I'm writing an application that provides an eye test on an Android tablet. The application requires around 280 images which in total are around 60mb. I've placed these images in the Resources folder and I tried loading them all using the LoadAll method of the Resources class...

 Sprite[] arr = Resources.LoadAll<Sprite>(folder);
 // organise the loaded sprites

This works well with a small number of images, but when my application tries to load them all it is automatically switched to a background task on the Android tablet and I can't keep it in the foreground. I'm not receiving any error messages when I try to debug the application in Android either. Can anyone suggest a reason for this behaviour and a possible fix?

Comment
Add comment · Show 4
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 davidcox70 · May 08, 2018 at 01:11 PM 2
Share

This is a complete guess, but perhaps Android is setting a task to background if it considers it "unresponsive" after a specific time. Perhaps try another way; load them in smaller batches and then let the frame update so that Android knows the program hasn't stalled. You could either iterate through a list of images using something like Resources.FindObjectsOfTypeAll, or you could arrange your images in batches in subfolders and LoadAll each subfolder. Loading them individually or as small batches in a co-routine would permit the occasional frame update to let Android all is progressing. Just a wild guess though.

avatar image xiak davidcox70 · May 08, 2018 at 01:34 PM 0
Share

Thanks for your reply! I really like the idea of using a co-routine to load smaller batches. Do you know if it's possible to do this with Resources.FindObjectsOfTypeAll without arranging my images into subfolders? I'm guessing it would work like Resources.LoadAll<type> and take a long time to execute?

avatar image davidcox70 xiak · May 08, 2018 at 01:40 PM 1
Share

FindAllObjects just creates a list of objects without loading them. $$anonymous$$ind of like getting a directory listing of a folder. So it should be pretty quick. You can then iterate through that list, loading the images as you go. You could arrange your loading loop such that it loads (say) 20 images at a time, before yielding to a frame update. This is also your opportunity to make a loading feedback progress bar for your users :-)

https://docs.unity3d.com/ScriptReference/Resources.FindObjectsOfTypeAll.html

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

81 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 avatar image avatar image avatar image

Related Questions

convert Resources.LoadAll("RPGOBJ", GameObject) to gameobject array? 0 Answers

Picture loaded from resource corrupted. 0 Answers

Best method for memory usage. 0 Answers

Having trouble with LoadAll 1 Answer

GUI layout Label Dimension issue 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