private void FindIslands(NavMeshCell cell) { Color[] colors = new Color[] { Color.red, Color.green, Color.blue, Color.yellow, Color.cyan, Color.magenta }; int index = 0; Queue <NavQuad> nodes = new Queue <NavQuad>(quadsTolinks.Keys); HashSet <NavQuad> visitedNodes = new HashSet <NavQuad>(); while (nodes.Count > 0) { var next = nodes.Dequeue(); if (visitedNodes.Contains(next)) { continue; } NavigationIsland island = new NavigationIsland(cell); islands.Add(island); foreach (var node in GraphSearch.BreathFirstSearch(next, GetAdjacentNodesForIslandSearch)) { visitedNodes.Add(node); quadsToIslands.Add(node, island); int i = index; } index++; index %= colors.Length; } }