- Home /
The question is answered, right answer was accepted
StartCoroutine namespace or type not found
Hello, everyone. I'm currently having an issue where I'm trying to call a Coroutine, but I get a namespace not found error on the StartCoroutine method. I have been able to call this method elsewhere in the project. My class declaration is as follows:
public class ModelTreeBuilder : MonoBehaviour {
public static IEnumerator CreateModelTree() { //call to StartCoroutine is made in here }
}
And my includes are:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Please let me know what I've missed.
Answer by Bunny83 · Sep 13, 2018 at 11:21 PM
StartCoroutine is an instance method of the MonoBehaviour class. So of course you can't use it inside a static method without providing a MonoBehaviour instance.
You haven't provided much context. The obvious change would be to remove the static keyword.
Yep, that was it. I completely overlooked that it was an instance method.
Answer by tormentoarmagedoom · Sep 13, 2018 at 06:23 PM
Good day.
This kind of errorse sometimes happens if the name of the method is not the same, or if you have some structure error , for missing some { } or some ( ) or maybe one additional innecessary { or } or ( ..
Check it.
Bye!
Thanks for the suggestion, but I don't think this is the case. The project and the rest of the Create$$anonymous$$odelTree function compiles fine without that line of code and intellisense doesn't suggest the method ether. Though I am able to access the Coroutine class.
Follow this Question
Related Questions
WaitForSeconds problem with Unity Pro 3 Answers
StartCoroutine fires once 1 Answer
How to force Coroutine to finish 1 Answer
Startcoroutine not working second time 2 Answers
Coroutines and states 1 Answer