Unity Coroutine NullReferenceException

时间:2017-07-12 00:09:22

标签: c# unity3d nullreferenceexception coroutine

我正在尝试学习如何在Unity中使用Coroutines,但我遇到了麻烦,并且一直遇到nullreferenceexception。

我已经在堆栈交换和统一的同一个问题上阅读了很多页面,但我似乎无法将答案与我自己的代码联系起来。

public void takeTopTask(Queue queue){
    if (availability == false) {
        Debug.LogError (name+" is not available to take a task");
    } else {
        task takenTask = (task)queue.Dequeue ();
        string taskName = takenTask.getName ();
        Debug.Log (taskName + " was taken by " + name);
        StartCoroutine(doTask(takenTask));
    }
}

IEnumerator doTask(task task){
    //do the task or something
    yield return new WaitForSeconds (task.getLength ());
}

任何帮助都会非常感激!

0 个答案:

没有答案