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 zharramadar · Aug 08, 2011 at 12:34 PM · terrainassetbundleasset

Asset Bundle load/unload problems

Hi everybody,

I'm having some trouble with Asset Bundles here. I have a script that runs in both the editor and during gameplay, and it is loading an array of 3x3 WWW objects, each one loading an asset bundle. Loading is not a problem, it is working perfectly, my problem is unloading it. I tried to load it, display the object the asset bundle contained, and keep it in memory until time to unload it, but this messed up when I went from editor to play, as for some reason my object loses reference in the array as soon as I press play, and then Unity complains my asset bundle is already loaded, and WWW fails. Because of that, I thought, why not load the asset bundle, get the object, and then destroy it right away? I tried this, and this worked nicely in the editor, but as soon as I press play, things get messed up with my 1st load, not loading my terrainData object. I thought, okay, as soon as I'm destroying the asset bundle and www object, it is destroying my TerrainData as well. Then I thought, okay, if it is being destroyed, I'll clone it with Instantiate() before destroying it, then there'll be no reference, and it indeed does clone my terrainData, but destroying all my splatmaps, trees and details.

What I need to know, is there any way to load an asset bundle with WWW, get a terrainData from it (assume it is the only asset in the bundle), destroy it right after loading and STILL get the terrainData, working both in runtime and editor? (sorry I don't have my code here, at work right now)

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by zharramadar · Sep 09, 2011 at 01:01 PM

Well, seems Unity doesn't provide any way to keep track of loaded/unloaded asset bundles, in Editor or in Runtime.... What I had to do is to make this control myself, and also deal with it on the script Awake and in its destruction, so when I switch off to either mode, the asset bundles get destroyed correctly. Then, I don't get any conflicts with Unity telling me I am loading an already loaded asset. Cloning the asset before destruction seemed useless and also behaved unpredictably.

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

Answer by msknapp · Sep 23, 2011 at 11:57 PM

I had a similar problem. My editor script was loading an asset bundle. The second time I ran the script, it told me that the asset bundle was already loaded, so cannot load again. I fixed this by calling this:

assetBundle.Unload(false);

This will make the asset bundle unload its data from runtime memory, but scene instances will remain in tact. Also, if you decide to load that asset bundle again later, unity will not complain because it is not considered in memory. If you call assetBundle.Unload(true), I think all of your scene instances will be destroyed.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

BCE0018 asset package giving error, folder is in standard assets. 0 Answers

Accessing BuildSettings from BuildSettings.asset 6 Answers

how to download Asset Bundles from website to Application.dataPath across platforms ? 1 Answer

AssetBundles - depend on asset already included in executable 0 Answers

Terrain splat 8 is null. 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