public static IEnumerator createHeightMap2()
    {
        bool  fin = true;
        float sT  = Time.realtimeSinceStartup;

        float[][] hm;

        lock (GameManager.tSets)
        {
            hm = (float[][])GameManager.tSets.globalHeightMap.Clone();
        }

        lock (GameManager.lSets)
        {
            GameManager.lSets.totalToFill += hm.Length * hm.Length;
        }

        CustomThreadPool.Instance.QueueUserTask(() =>
        {
            GenerationMethods thisGen = new GenerationMethods();
            Debug.Log("Heightmap " + hm.Length + "x" + hm.Length + " started");
            for (int x = 0; x < hm.Length; x++)
            {
                for (int z = 0; z < hm[x].Length; z++)
                {
                    //hm[x][z] = initHeight + Mathf.PerlinNoise (x / initDetailScale, z / initDetailScale) * initHeightScale;
                    hm[x][z] = thisGen.OctavePerlin((double)x / initDetailScale, (double)z / initDetailScale, 0.0, 3, 2f);
                }

                lock (GameManager.lSets)
                {
                    GameManager.lSets.totalFilled += hm.Length;
                }
                Thread.Sleep(0);
            }
        },
                                                (ts) =>
        {
            fin = false;
        });

        while (fin)
        {
            yield return(new WaitForSeconds(0.5f));
        }

        lock (GameManager.tSets)
        {
            GameManager.tSets.globalHeightMap = (float[][])hm.Clone();
            GameManager.tSets.isHeightSet     = true;
            float eT = Mathf.Round(100f * (Time.realtimeSinceStartup - sT)) / 100f;
            Debug.Log("Heightmap finished after " + eT + " seconds");
        }
    }
    public static IEnumerator createWaterMap()
    {
        bool  fin     = true;
        float sT      = Time.realtimeSinceStartup;
        int   length1 = 0;
        int   length2 = 0;

        lock (GameManager.tSets)
        {
            length1 = GameManager.tSets.globalWaterMap.Length;
            length2 = GameManager.tSets.globalWaterMap [0].Length;
        }

        lock (GameManager.lSets)
        {
            GameManager.lSets.totalToFill += length1 * length2;
        }

        float[][] wm = new float[length1][];
        for (int i = 0; i < length1; i++)
        {
            wm [i] = new float[length1];
        }

        CustomThreadPool.Instance.QueueUserTask(() =>
        {
            GenerationMethods thisGen = new GenerationMethods();
            Debug.Log("Watermap " + length1 + "x" + length2 + " started");
            for (int x = 0; x < length1; x++)
            {
                for (int z = 0; z < length2; z++)
                {
                    float jk = thisGen.OctavePerlin((double)x / length1 * 2f, (double)z / length2 * 2f, 0.0, 3, 2f);
                    jk       = Interpolations.cubicBezierEaseCurve(3f, 0f, -2f, 1f, jk);

                    wm [x][z] = jk;
                }

                lock (GameManager.lSets)
                {
                    GameManager.lSets.totalFilled += length1;
                }
                Thread.Sleep(0);
            }
        },
                                                (ts) =>
        {
            fin = false;
        });

        while (fin)
        {
            yield return(new WaitForSeconds(0.5f));
        }

        lock (GameManager.tSets)
        {
            GameManager.tSets.globalWaterMap = (float[][])wm.Clone();
            GameManager.tSets.isWaterSet     = true;
            float eT = Mathf.Round(100f * (Time.realtimeSinceStartup - sT)) / 100f;
            Debug.Log("Watermap finished after " + eT + " seconds");
        }
    }