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 jz87 · Apr 09, 2012 at 06:27 AM · wwwyield

Custom yield return

I would like to implement my own WWW class to make calls to web APIs. Is there anyway I can use yield return with my own class?

Is there some API in Unity that allows me to perform an async operation, BeginA and call yield return and then call EndA to signal to unity to resume?

Comment
Add comment · Show 4
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 flamy · Apr 09, 2012 at 07:06 AM 0
Share

just a suggestion if you are making a custom class for www, why dont you use Thread Class from .Net ins$$anonymous$$d of StartCoroutine.

avatar image jz87 · Apr 09, 2012 at 09:39 AM 0
Share

What do you mean? I don't understand what you're trying to say.

avatar image GuyTidhar · Apr 09, 2012 at 10:24 AM 0
Share

Threads are what is usually used in program$$anonymous$$g to make parallel and async operations. If you haven't heard of it, it is probably too complex for you to handle at this point. So could you explain more about what custom function are you hoping to achieve? Coroutines (the functions that make use of yield) are much simpler to grasp then classic threading...

avatar image jz87 · Apr 09, 2012 at 01:18 PM 0
Share

lol, I didn't mean I don't know what threads are, but rather why the suggestion of using threads. I wanted to integrate WCF services into my unity app, and making synchronous calls to remote services in the main application loop would be a horrible idea. Since I would rather not get into having to keep track of what thread my code is running on and what they can and can't access (plus being paranoid about using concurrent data structures).

Actually I should close this question since I did some research and figured out how to implement this. Just wrote a behavior that went through a list of async operations in FixedUpdate and checked their IAsyncResult for completion.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Paulius-Liekis · Apr 09, 2012 at 02:53 PM

You can always have a function (which returns iEnumerator) in your class you you can yield that.

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

WWW execution (working in browser) 2 Answers

Issues with WWW resource loading 1 Answer

How to yiled a try/catch block? 2 Answers

WWW/ yield calls throwing errors on iPad 1 Answer

yield return on WWW never coming back? 0 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