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
1
Question by Bork Awesome · Jan 10, 2013 at 11:52 AM · gameobjectdestroymemoryresources

UnloadAsset with GameObject best practice?

It appears that a GameObject loaded by Resources.Load() cannot be unloaded by Resources.UnloadAsset() - an error with the following message is thrown:

"UnloadAsset may only be used on individual assets and can not be used on GameObject's / Components or AssetBundles"

This has been documented multiple times in prior questions and forum threads:

  • http://answers.unity3d.com/questions/16020/how-can-i-unload-a-single-resource.html

  • http://answers.unity3d.com/questions/260144/resourcesunloadasset.html

  • http://forum.unity3d.com/threads/142807-How-to-UnloadAsset

  • http://forum.unity3d.com/threads/155553-Combinee-meshes-still-not-released-from-memory

I believe the issue is a GameObject is a container class and UnloadAsset() handles only individual assets i.e. Texture.

Has anybody got a solution or best practice for cleaning up the components/memory of a GameObject loaded by Resources.LoadAsset() apart from the obvious and complete overkill call to Resources.UnloadUnusedAssets() which walks the entire object tree every call?

Comment
Add comment · Show 5
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 FWCorey · Jan 10, 2013 at 12:10 PM 0
Share

Have you tried unloading all of it's components and child components then destroying the empty gameobject? (haven't run into this issue before myself since I've never used Resources.Load for a GameObject)

avatar image Bork Awesome · Jan 10, 2013 at 12:19 PM 0
Share

@FWCorey: Good suggestion. I had pondered that, but not tried for the following reasons:

  • You can't unload components, only assets, so would have to derive the component type, then write code to leech out the asset to unload. Given I am loading GameObjects that could contain InteractiveCloth, LODGroups, $$anonymous$$eshes etc. this would be a monster task.

  • Destroying the root GameObject actually destroys the asset/prefab full stop, poof and it's gone from your project :(

As I'm a Pro user I'm pondering AssetBundles but that seems like overkill and a pain for iteration. I was asking this with everything crossed for a nice, elegant silver bullet answer :D

avatar image FWCorey · Jan 10, 2013 at 12:38 PM 0
Share

What about putting the asset in an empty scene ins$$anonymous$$d of a resource, loading it additively then destroying the instance? I don't have pro and that's how I stream assets.

avatar image Bork Awesome · Jan 10, 2013 at 12:56 PM 0
Share

@FWCorey: Yup another good suggestion. Problem there is there are so many of them and they are relatively small - over 30 at the moment - and this number will extend over time; this would give me a maintenance nightmare with flooding the project with excess scenes and having to manage them through the Player etc.

avatar image maxxa05 · May 02, 2015 at 03:09 AM 0
Share

I guess there is still no development regarding this?

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

11 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

Related Questions

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

Destroy single asset from AssetBundle 2 Answers

How does resource loading and instantiating consume memory 0 Answers

Trying to make a simple inventory: 0 Answers

Destruct gameobject by call from another script 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