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 jacky_unity · Nov 11, 2013 at 10:50 PM · optimizationloadingmemoryresources

Long load time for scene... Some optimization questions.

I apologize if this has been answered before but I could not find a satisfactory answer to this question.

I have a scene that has many different activities that are similar in nature but have separate resources. They are not similar enough to use the same code but not different enough to be in separate scenes. I created several empty GameObjects to act as a container for each "mini-scene". I call, for example, PartOne.SetActive(true) when I want it to be visible and set it to false when I want it to turn off.

Looking back, perhaps creating several different scenes and calling LoadLevelAdditive (asynchronously or not) may have been better but I really don't have time to refactor right now.

There are a couple of questions that I can't find the answers to in the Unity documentation (or anywhere for that matter) that could help me out. Of course, any other ideas are also welcome.

  1. If I create a public variable and drag a texture (for example) to it in the inspector, is that texture loaded into memory when the scene is loaded or does it cache it somehow?

  2. If I create said public variable and it is the child of another GameObject, is the parent (as well as the other items in that hierarchy) loaded into memory?

  3. If a child GameObject is active but it's parent is not, are the children loaded into memory?

  4. Is using Resources.Load too slow to load high-res images?

  5. Is there any way to cache images in a temp directory or any other magical feature that I am missing?

Thanks! Any other feedback or ideas would be appreciated!

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 Jessespike · Nov 12, 2013 at 03:01 AM

I answered these questions the best I could. I may be wrong, if that's the case then I hope someone will correct me.

1) When the scene starts, the texture will have been loaded into memory. If you have two public variables referencing the same texture, more memory is used. Even though they're the same texture, each reference will take up memory. There is no texture sharing or caching.

2) Yes, the entire hierarchy will be loaded into memory, even if it's inactive.

3) Yes

4) Depends on you're definition of "too slow". Also depends on what hardware you're targeting. I would imagine, loading multiple high-res images would cause a stutter at least, maybe even freeze for a couple of seconds on slower machines.

5) Perhaps you could pool your textures with a "TextureCache" or manager. Have a singleton class DontDestroyOnLoad and have a public list of materials, so you can store a single reference of each texture. Then, when you need a specific texture/material you can grab it from here. (Don't know if this applies to you're project, just throwing ideas.)

I'm guessing you already compressed the textures to a compatible format and making use of sharedMaterials. But if you haven't then that would a be a good idea. Other things that may improve texture load times would be removing mipmaps (when not needed). Reducing texture sizes. Make sure texture resolution is a power of 2. Disabling read/write. Use masks for transparency instead of alpha. If you have two or more identical textures but they vary in color, then use one grayscale version and use a shader to color them. Use atlases for GUI and sprites. Combine smaller textures.

http://docs.unity3d.com/Documentation/Manual/iphone-PracticalScriptingOptimizations.html#Object%20Pooling http://docs.unity3d.com/Documentation/Manual/Textures.html

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 jacky_unity · Nov 12, 2013 at 06:03 PM 0
Share

Thank you so much! I suspected many of these things but it is good to have them confirmed.

We have done most of the things that you suggested above but a few that we haven't. Thanks again!

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

17 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

Related Questions

How to have 2 sets of textures and make sure only one is loaded? 0 Answers

Prevent Resources class from loading assets when application starts 1 Answer

How to determine which resources are loaded while loading scene 1 Answer

AssetBundles, memory, and loading 0 Answers

Do I need to manually call Resources.UnloadUnusedAssets? 0 Answers


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