void generateMesh()
    {
        MeshMaker meshMaker = new MeshMaker();

        bool[,] extendedGrid = GrowPassabilityGrid();

        for (int x = 0; x < width + 2; x++)
        {
            for (int y = 0; y < height + 2; y++)
            {
                List <Vector3> l  = new List <Vector3>();
                List <Vector2> uv = new List <Vector2>();
                if (extendedGrid[x, y])
                {
                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) - (tileScale / 2), 0, ((y - (height + 2) / 2) * tileScale) - (tileScale / 2)));
                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) + (tileScale / 2), 0, ((y - (height + 2) / 2) * tileScale) - (tileScale / 2)));
                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) + (tileScale / 2), 0, ((y - (height + 2) / 2) * tileScale) + (tileScale / 2)));
                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) - (tileScale / 2), 0, ((y - (height + 2) / 2) * tileScale) + (tileScale / 2)));
                    uv.Add(new Vector2(0.01f, 0.76f));
                    uv.Add(new Vector2(0.24f, 0.76f));
                    uv.Add(new Vector2(0.24f, 0.99f));
                    uv.Add(new Vector2(0.01f, 0.99f));
                    meshMaker.AddQuad(l.ToArray(), uv.ToArray());


                    for (int x1 = -1; x1 <= 1; x1++)
                    {
                        for (int y1 = -1; y1 <= 1; y1++)
                        {
                            l.Clear();
                            uv.Clear();
                            Vector2 scanVec = new Vector2(x + x1, y + y1);
                            if (scanVec.x < 0 || scanVec.x >= width + 2 || scanVec.y < 0 || scanVec.y >= height + 2 || (Mathf.Abs(x1) == Mathf.Abs(y1)))
                            {
                                continue;
                            }
                            else if (!extendedGrid [(int)scanVec.x, (int)scanVec.y])
                            {
                                if (x1 != 0)
                                {
                                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) + ((tileScale * x1) / 2), wallHeight, ((y - (height + 2) / 2) * tileScale) - ((tileScale * x1) / 2)));
                                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) + ((tileScale * x1) / 2), wallHeight, ((y - (height + 2) / 2) * tileScale) + ((tileScale * x1) / 2)));
                                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) + ((tileScale * x1) / 2), 0, ((y - (height + 2) / 2) * tileScale) + ((tileScale * x1) / 2)));
                                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) + ((tileScale * x1) / 2), 0, ((y - (height + 2) / 2) * tileScale) - ((tileScale * x1) / 2)));

                                    uv.Add(new Vector2(0.74f, 0.99f));
                                    uv.Add(new Vector2(0.51f, 0.99f));
                                    uv.Add(new Vector2(0.51f, 0.76f));
                                    uv.Add(new Vector2(0.74f, 0.76f));
                                    meshMaker.AddQuad(l.ToArray(), uv.ToArray());
                                }
                                else
                                {
                                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) + ((tileScale * y1) / 2), wallHeight, ((y - (height + 2) / 2) * tileScale) + ((tileScale * y1) / 2)));
                                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) - ((tileScale * y1) / 2), wallHeight, ((y - (height + 2) / 2) * tileScale) + ((tileScale * y1) / 2)));
                                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) - ((tileScale * y1) / 2), 0, ((y - (height + 2) / 2) * tileScale) + ((tileScale * y1) / 2)));
                                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) + ((tileScale * y1) / 2), 0, ((y - (height + 2) / 2) * tileScale) + ((tileScale * y1) / 2)));

                                    uv.Add(new Vector2(0.74f, 0.99f));
                                    uv.Add(new Vector2(0.51f, 0.99f));
                                    uv.Add(new Vector2(0.51f, 0.76f));
                                    uv.Add(new Vector2(0.74f, 0.76f));
                                    meshMaker.AddQuad(l.ToArray(), uv.ToArray());
                                }
                            }
                        }
                    }
                }
                else
                {
                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) - (tileScale / 2), wallHeight, ((y - (height + 2) / 2) * tileScale) - (tileScale / 2)));
                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) + (tileScale / 2), wallHeight, ((y - (height + 2) / 2) * tileScale) - (tileScale / 2)));
                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) + (tileScale / 2), wallHeight, ((y - (height + 2) / 2) * tileScale) + (tileScale / 2)));
                    l.Add(new Vector3(((x - (width + 2) / 2) * tileScale) - (tileScale / 2), wallHeight, ((y - (height + 2) / 2) * tileScale) + (tileScale / 2)));
                    uv.Add(new Vector2(0.26f, 0.76f));
                    uv.Add(new Vector2(0.49f, 0.76f));
                    uv.Add(new Vector2(0.49f, 0.99f));
                    uv.Add(new Vector2(0.26f, 0.99f));
                    meshMaker.AddQuad(l.ToArray(), uv.ToArray());
                }
            }
        }

        mf.mesh       = meshMaker.mesh;
        mc.sharedMesh = meshMaker.mesh;
    }