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
2
Question by Max Kaufmann · Jan 08, 2010 at 09:19 PM · webplayerassetbundleweb

yield on WWW? or AssetBundleRequest? or both?

I'm trying to write a generic manager for all downloads, and I really want to understand what asynchronous and what's blocking.

I wrote the following and it worked:

WWW www = new WWW(mUrl);
yield return www;
AssetBundleRequest request = www.assetBundle.LoadAsync("Cube", typeof(Object));
yield return request;
Instantiate(request.asset);

But so does this (I don't seem to need to yield on www):

WWW www = new WWW(mUrl);
AssetBundleRequest request = www.assetBundle.LoadAsync("Cube", typeof(Object));
yield return request;
Instantiate(request.asset);

Is the application blocking in the www.assetBundle getter? Or is this equivalent to the former (i.e. the download occurs during the yield on request)?

Comment
Add comment · Show 1
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 Helical · Nov 06, 2018 at 10:13 AM 0
Share

Adding my 2 cents from 2018, You can also listen to .completed event inside the AssetBundleRequest object.

request.completed += (operation)=> { /do stuff/ };

Also you should not forget to Dispose the WWW object,

And its wierd that its letting you Instantiate something of type Object

2 Replies

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

Answer by Lucas Meijer 1 · Jan 09, 2010 at 03:43 PM

There's several things going on here.

  • The download of the bytes of the assetbundle
  • The creation of an assetbundle object from those bytes
  • The creation of the Cube object, based on the description of the cube in the assetbundle.

Step 1 and 3 you are yielding on. As Jonas points out that's a good idea. Step 2 we actually don't (yet) allow you to do asynchronously. This is not a big thing, as it's typically a very fast step, that doesn't cause a hickup.

Whenever you're using AssetBundle's it's good practice do use the Asynchronous API to load objects from them, as if you do so, the loading process happens on a seperate thread, which is tech speak for "you wont get a hickup". This API is new since Unity2.6, there's a similar api for loading entire scenes/levels.

Bye, Lucas

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 metaleap · Sep 19, 2013 at 04:34 AM 0
Share

I'm really confused with the WWW.assetBundle property. It does some decompression and returns an AssetBundle object. But nothing inside it is "Loaded" yet, right? Until we Load() assets from the AssetBundle. So is it simply "all uncompressed bytes in RA$$anonymous$$, ready for your loading"? And then there's Unload(false) to unload the compressed bytes from RA$$anonymous$$. So if we never call this, those stay in RA$$anonymous$$, but would there ever be a conceivable benefit in keeping those in RA$$anonymous$$?.....

avatar image
3

Answer by jonas-echterhoff · Jan 09, 2010 at 01:12 PM

You are correct. The latter code snippet works, because the application blocks in the WWW.assetBundle getter. The first code snippet is preferable, as it lets your game continue while the data is downloaded.

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 Brian-Kehrer · Jan 09, 2010 at 08:29 PM 0
Share

Oops. I've had that confused all this time too...

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

2 People are following this question.

avatar image avatar image

Related Questions

How to import the object from server to unity 2 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Web build: WWW downloads correctly, but www.assetBundle is Null 0 Answers

What is the maximum byte length of Application.ExternalCall? (and oh yea, it doesn't escape strings correctly) 3 Answers

What kind of error handling does the WWW class have? 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