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 jvt619 · Dec 01, 2013 at 01:15 PM · yieldienumerator

IEnumerator does not exist

 using UnityEngine;
 using System.Collections;
 
 public class DoorLogic : MonoBehaviour {
 
     public float guiBoxWidth;
     public float guiBoxHeight;
 
     public Transform theDoor;
 
     private bool drawGUI = false;
     public bool isClosed = true;
 
     // Update is called once per frame
     void Update () 
     {
         if (drawGUI == true && Input.GetKeyDown (KeyCode.E)) 
         {
             ChangeDoorState();
         }
     }
 
 
     void OnTriggerEnter(Collider collider)
     {
         if (collider.tag == "Player") 
         {
             Debug.Log("Working");
             drawGUI = true;
         }
     }
 
     void OnTriggerExit(Collider collider)
     {
         if (collider.tag == "Player") 
         {
             Debug.Log("Exit Working");
             drawGUI = false;
         }
     }
 
     void OnGUI()
     {
         if (drawGUI == true) 
         {
             if (isClosed == true)
                 GUI.Box (new Rect ((Screen.width / 2) - 51, 10, guiBoxWidth, guiBoxHeight), "Press E to Open");
 
             else
                 GUI.Box (new Rect ((Screen.width / 2) - 51, 10, guiBoxWidth, guiBoxHeight), "Press E to Close");
         }
     }
 
     void ChangeDoorState()
     {
         if (isClosed == true) 
         {
             theDoor.animation.CrossFade ("Opening");
             isClosed = false;
         }
 
         StartCoroutine (doorDelay(2));
 
         theDoor.animation.CrossFade ("Close");
         isClosed = true;
     }

    //IEnumerator is in redfont.
     IEnumerator doorDelay(float delaySec)
     {
         yield return new WaitForSeconds(delaySec);
     }
 }
 

I get this error "The name 'IEnumerator' does not exist in the current context". and the IEnumerator is in redfont.

alt text

Comment
Add comment · Show 9
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 fafase · Dec 01, 2013 at 01:58 PM 0
Share

What is before that? You are probably missing a } just before.

avatar image jvt619 · Dec 01, 2013 at 02:47 PM 0
Share

nothing is missing, it's just i cant use it and i don't know why

avatar image paulygons · Dec 01, 2013 at 03:54 PM 0
Share

I put this script in my Unity project and get no warnings. That code doesn't seem to be the problem.

avatar image jvt619 · Dec 01, 2013 at 04:06 PM 0
Share

the IEnumerator is in red fonts on the $$anonymous$$onoDevelop

avatar image fafase · Dec 01, 2013 at 04:06 PM 0
Share

You might be facing the case where you need to copy paste your script, delete it, create a new one and paste the code. $$anonymous$$agically some non existing errors disappear this way.

Show more comments

6 Replies

· Add your reply
  • Sort: 
avatar image
7

Answer by ababab5 · May 06, 2015 at 02:19 PM

if it's not the case, try to add "using System.Collections"

I know you put it in your copy and paste , but In my case it was 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
avatar image
1

Answer by Marc Ollivrin · Apr 02, 2014 at 09:39 AM

@fullme7al : I think it's a bug too.

I'm trying to follow the Space Shooter tutorial and get the same error "CS0103" ... I am under Windows 8.1 too. Could this be related to a version of the .Net framework installed (or missing) on the system ? Maybe trying to install a 3.5 version of the .Net framework for Windows 8.1 could do it, is it possible ?

Updated, some hours later : In fact, it was : under Windows 8.1, only the 4.5 or 4.0 versions ('don't remember) of the .net framework are installed and activated. The 3.5 is available, but not activated by default. After following the procedure given here : http://msdn.microsoft.com/fr-fr/library/hh506443%28v=vs.110%29.aspx, i have activated the 3.5 version (and after some additional file download), re-opened Unity 3D, checked my script (the GameController in the Space shooter tutorial) and IEnumerator is now properly identified and the script works !

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
1

Answer by dennyroberts · Jun 30, 2017 at 03:56 PM

I know this is old, but just found this from Google so I thought I'd comment.

I just had the same issue and it was fixed by restarting Unity.

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 elyasaf755 · Jul 23, 2018 at 05:13 PM 0
Share

This is actually works!!! Thank you!

avatar image
-2

Answer by morteza_asadpour · Dec 02, 2013 at 06:59 AM

befor use IEnumerator , Use void : void IEnumarator DoorDalay(float delaySec) { yield return new WaitForSeconds(delaySec); }

Comment
Add comment · Show 10 · 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 jvt619 · Dec 02, 2013 at 08:34 AM 0
Share

nope doesn't work

avatar image fullme7al · Dec 22, 2013 at 09:11 AM 1
Share

Does anyone else have this problem? or solve it? I'm getting the same error as OP in all of my scripts with IEnumerators on my project. Putting void before Ienumerator turns the name of the enumerator blue and throws up several other errors. Is this a bug? I'm up to date on $$anonymous$$onodevelop and Unity. I'm also running Windows 8.1, I wonder if it has something to do with that.

avatar image vexe · Dec 22, 2013 at 09:41 AM 1
Share
  • @morteza_asadpour dude... void IEnumerator? void in "void my$$anonymous$$ethod(){}" signifies that my$$anonymous$$ethod doesn't return anything. IEnumerator in "IEnumerator my$$anonymous$$ethod() {yield return something;}" means that my$$anonymous$$ethod will return an "`IEnumerator`" - you can't put two return types in your method signature. Please learn your basics before you start posting answers.

avatar image retlaw · Feb 12, 2014 at 02:52 PM 0
Share

I get the same errors in all of my scripts and also in the Script "GameController" in the "Done/Done_Script" - Folder of the Shooter Tutorial

"Error CS0103: The name 'IEnumerator' does not exist in the current context"

Any Solutions??

avatar image fullme7al · Feb 13, 2014 at 03:38 AM 0
Share

What Operating system are you using? I'm using windows 8.1 and ienumerators dont work at all, whether they are my scripts or unity imported projects.I think it is a bug.

Show more comments
avatar image
0

Answer by RedDevil · Feb 12, 2014 at 03:22 PM

I tryed your script and i get no error.Try making a new script and copy everything from it again.

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
  • 1
  • 2
  • ›

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

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

Related Questions

Create a class like WWW which a IEnumerator will wait on. 0 Answers

Yield Wait for Seconds (A little help here) 2 Answers

Only the first half of my coroutine works 1 Answer

Wait For Seconds c# 3 Answers

IEnumerator solution! 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