Even though this recipe is only for defining a function, please take into consideration the comments in the code for a better understanding of the implementation and code flow:
- Modify the Graph class and add a couple of member variables, one for storing the path and the other for knowing whether the coroutine has finished:
public List<Vertex> path; public bool isFinished;
- Declare the member function:
public IEnumerator GetPathInFrames(GameObject srcObj, GameObject dstObj, Heuristic h = null) { //next steps }
- Include the following member variables at the beginning:
isFinished = false; path = new List<Vertex>(); if (srcObj == null || dstObj == null) { path = new List<Vertex>(); isFinished = true; yield break; }
- Modify ...