• 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
1
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
Add comment · 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
3
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
Add comment · 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 $$anonymous$$onoBehavior 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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Halo effect perfomance on mobile devices 1 Answer

Best way to create/design modular Player 2 Answers

iPhone 4 game lags 2 Answers

Does assetbundle work well with mobile devices? 1 Answer

set minimum texture resolution? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges