• 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
Question by demize2010 · May 08, 2011 at 01:09 AM · androidiphoneperformancematerialsmemory

Memory Managmenet

Hey guys,

I was wondering if objects are loaded into memory when they are referenced by scripts?

For example, imagine we have a single game object with a mesh renderer. On this object we have a script which allows the player to change the material to one of 10 materials. Are all 10 materials loaded into memory on level start, or are they loaded as required?

Thanks in advance! -Jack

Comment
burgunfaust

People who like this

1 Show 2
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 Henrique Vilela · May 08, 2011 at 04:58 AM 0
Share

Good question. I would guess that they are loaded, but would also like to know the answer.

avatar image demize2010 · May 23, 2011 at 01:16 PM 0
Share

Anyone got any idea on this? I think they are actually loaded into memory from what I can see...

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Statement · May 23, 2011 at 01:41 PM

I don't have any reference to support this, but I'd say that they are loaded if you have a reference to it (for example if you bind it through the inspector). What you can do is place them in the Resources folder and load them dynamically, if you need to avoid having them loaded when they aren't used.

Use Resources.Load to load any sort of asset, including materials.

See also Resources.UnloadUnusedAssets and Object.Destroy.

Comment
Joshua
demize2010
DonKanallie

People who like this

3 Show 4 · 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 Joshua · May 23, 2011 at 01:45 PM 0
Share

I also couldn't find any documentation, but I'm quite sure you're correct.

avatar image demize2010 · May 23, 2011 at 02:14 PM 0
Share

@Statenement & @Joshua Thanks guys, this Resources class looks handy :)

avatar image demize2010 · May 23, 2011 at 02:19 PM 0
Share

Suspect this is how the load logic works as well "An asset is deemed to be unused if it isn't reached after walking the whole game object hierarchy, including script components. Static variables are also examined." From UnloadUnusedAssests

avatar image DonKanallie · Jun 26, 2014 at 11:23 AM 0
Share

I did a quick test and using the Unity Profiler for an app running on an iPhone and this answer answer did prove to be true. A simple reference in an MonoBehavior is enough to get the texture loaded into memory.

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.

Update about the future of Unity Answers

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta later in June. Please note, we are aiming to set Unity Answers to read-only mode on the 31st of May in order to prepare for the final data migration.

For more information, please read our full announcement.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Does using "half res" in the quality settings reduce texture RAM usage? 1 Answer

Best practices for smart phone development 1 Answer

Slow Startup on iOS and Android 1 Answer

Why do textures take double memory on iOS and Android devices? 1 Answer

Specular Materials on iPhone or Android? 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