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 meganeroppy · Mar 25, 2020 at 11:34 PM · textureruntimesaveload

Is it possible to save loaded textures and reuse after close app?

HI. I would like to know whether it's possible to save textures loaded from paths. My app have a function that load thousands of textures from paths than it takes a lot like few minutes. Even I want to use textures again that totally the same as one previously loaded, I have to load them and wait till this process completes in every launching if I close my app and open it later. Hopefully there's a way to save these textures after it's loaded once, than from the 2nd time just reuse them in runtime without that loading phase.

Thank you.

 IEnumerator LoadTexturesFromPath(  string[] _decodedImageFiles )
 {
 // _decodedImageFiles.Length is about 3000+
 Texture2D[] texs = new Texture2D[ _decodedImageFiles.Length ];
 
 // this loop costs about a few minutes
   for (int i = 0; i < _decodedImageFiles.Length; ++i)
             {
                 var path = _decodedImageFiles[i];
                 Texture2D tex = null;
                         using (var request = UnityWebRequestTexture.GetTexture(path, true))
                         {
                             yield return request.SendWebRequest();
 
                             tex = DownloadHandlerTexture.GetContent(request);
                         }
                     texs [i] = tex;
             }
 
 // love to save this loadResult.
             loadResult= texs ;
 }
 
 /////// want to do like this
 
 Texture2D[] loadedTextures, loadResult;
 bool loaded;
 
 IEnumerator Start()
 {
     if(loaded)
     {
        // from the 2nd time
        loadedTextures = GetLoadedTexture();
     }
     else
     {
         // only at the 1st time
         yield return LoadTexturesFromPath();
         loadedTextures = loadResult;
     }
 
     // use loadedTextures
     // .......
 }
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 dacarrera · Mar 26, 2020 at 02:40 AM

When you close the app, the process running dies. This frees all of the memory that was being used, which is why you need to reload your textures each time you re open your app. Leaving thousands of textures loaded (in memory, ready to go) would mean dedicating tons of memory (depending on the size, think 1+GB of RAM). This is especially problematic if it's a mobile app where battery drainage also comes in to play.

I'm not sure what you're using thousands of textures at the same time for, but is spacing this out (loading them just when you actually need to use them) not an option? Several minutes of hang on each open for a seemingly unnecessary amount of textures all at once really isn't something that should be pursued.

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

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

Related Questions

Load texture and shaders at runtime on iPhone 2 Answers

Android download and save "Resources.assets" 0 Answers

my textures aren't working (bmp files issue) 3 Answers

How do I save/restore a procedurally generated mesh in runtime in Unity 5? 2 Answers

Serialize GameObject 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