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 MrVerdoux · Dec 24, 2013 at 08:40 AM · yieldienumeratorienumerable

IEnumerable in Unity

That´s right, I´m not asking about IEnumerators, I know how to start a coroutine. The thing is that I have been trying to improve my understanding of yield in C#, and I noticed that in the microsoft documentation the don´t use IEnumerator at all when using yield, in fact it looks to me that they are trying to avoid it to keep things simple.

So, what uses would IEnumerable have in Unity? why is IEnumerator used with yield and not IEnumerable?

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

1 Reply

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

Answer by Jessy · Dec 24, 2013 at 02:00 PM

There's nothing special about these interfaces in Unity, aside from Unity using an outdated version of Mono, making them less efficient than we'd all like. I still use IEnumerable a ton, due to LINQ making code shorter and more easily readable. It doesn't make sense to use a garbage collected language for game development, but that's what we've got, so embrace the suck! :-P Alter your code to something more archaic, after profiling, if necessary.

http://www.youtube.com/watch?v=jd3yUjGc9M0

http://stackoverflow.com/questions/619564/what-is-the-difference-between-ienumerator-and-ienumerable

which links to more good answers: http://stackoverflow.com/questions/558304/can-anyone-explain-ienumerable-and-ienumerator-to-me

Despite heavy use of IEnumerable, I never find myself having to implement IEnumerator itself. (These two Interfaces should be generic, with two arrows and a T in the middle, but the site makes them disappear. Please edit this if you know how to bring them back. I never use the non-generic forms.)

Comment
Add comment · Show 2 · 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 MrVerdoux · Dec 26, 2013 at 05:10 PM 0
Share

I was expecting something special about them, as it happens with IEnumerators. $$anonymous$$aybe I´m wrong but I think we can use IEnumerators as coroutines because they are handled in a special way by the engine (how, otherwise, would null equal one frame?). Any way, good answer! Thank you!

avatar image mitul514 · Jul 30, 2019 at 06:31 AM 0
Share

Thank you it helped a lot

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

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

Related Questions

Corutine not behaving like it should? 1 Answer

IEnumerator does not exist 6 Answers

Increase variable for a few seconds 2 Answers

[ Coroutine: Move Next ] CPU usage 0 Answers

Coroutoutine doesnt work properly. 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