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
0
Question by andresp · Nov 08, 2012 at 02:15 PM · c#wwwyield

yield return www - What is www referring to?

In the instruction:

 yield return www;

which method is being called in the WWW class of the www variable?

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 andresp · Nov 15, 2012 at 01:44 PM 0
Share

for anyone interested: http://gamedev.stackexchange.com/questions/43749/the-underlying-mechanism-in-yield-return-www-of-unity3d-game-engine

avatar image whydoidoit · Nov 15, 2012 at 01:47 PM 0
Share

Hey should have probably pointed out that they are also discussed in detail here

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by whydoidoit · Nov 08, 2012 at 02:30 PM

It's not calling a method - its waiting for the object to say that its done and then continuing.

something like:

  while(!www.isDone)
      yield return null;
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 andresp · Nov 09, 2012 at 01:01 AM 0
Share

can you explain how it is waiting for the object to say that its done if it's only referencing the variable name?

I would understand your logic if it was: yield return www.WaitTillDone();

and even then, the execution would be blocked till WaitTillDone returned, right?

avatar image whydoidoit · Nov 15, 2012 at 01:49 PM 0
Share

Hey sorry, just saw this per your comment above about stackexchange.

That code is the same as waiting for the object with yield return www;

That's because internally the implemented YieldInstruction on WWW just waits for the completion signal before indicating that it can continue. If you want to be involved in the process, then the code I've posted does exactly the same thing, but you could choose to abort if the process had taken too long - not an option with the normal yield.

avatar image andresp · Nov 15, 2012 at 02:00 PM 0
Share

so you consider that the download is being done asynchronously on a different thread (which starts by calling the WWW constructor), right? As it was pointed out on stackexchange, the main Unity thread seems to be, at least, responsible for the change in the www.isDone field.

http://gamedev.stackexchange.com/a/43778/10590

avatar image whydoidoit · Nov 15, 2012 at 02:03 PM 2
Share

Yes that's pretty much it - all coroutine processing and actually anything to do with a Unity object publicly is done on the main thread (to avoid their thread access exceptions).

So there will be some internal value that is being changed on completion, that thread then queues up a main thread change of the isDone value - actually this article I wrote shows how you can achieve that with your own threads - I guess that they are doing something similar.

avatar image
0

Answer by Landern · Nov 08, 2012 at 02:29 PM

you are waiting for something to download, wait for it to complete then return the www object.

Documentation of WWW class.

Quote from the documentation:

Simple access to web pages.

This is a small utility module for retrieving the contents of URLs.

You start a download in the background by calling WWW(url) which returns a new WWW object.

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 andresp · Nov 08, 2012 at 02:41 PM 0
Share

I know what it is used for, my question is about what specific mechanism is being used to wait for the WWW process to return. Typically a C# yield statement implements a state machine which controls the different operations and return values based on its current state (# of calls already performed). I don't understand how is this process being used here.

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

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Another yield and www question 2 Answers

yield www loading local file blocks UI 0 Answers

Flip over an object (smooth transition) 3 Answers


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