private void StartGenerating()
        {
            if (importHeightMap)
            {
                heightMap = ExternalHeightMapReceiver.Generate();
                Debug.Log("Height map");
            }
            else
            {
                switch (generationAlgorithm)
                {
                case GenerationAlgorithm.PerlinNoise:
                {
                    heightMap = PerlinNoiseGenerator.Generate(mapSize);
                    break;
                }

                case GenerationAlgorithm.DiamondSquare:
                {
                    heightMap = DiamondSquareGenerator.Generate(mapSize);
                    break;
                }
                }
            }

            var mapGen = (MapGenerator)target;

            switch (optimizationMethod)
            {
            case Optimization.LevelOfDetail:
            {
                optimizedMap = LevelOfDetailOptimizer.Optimize(heightMap);
                mapGen.GenerateRegularMesh(optimizedMap);
                break;
            }

            case Optimization.RamerDouglasPecker:
            {
                optimizedMap =
                    RamerDouglasPeckerOptimizer.Optimize(heightMap, PerlinNoiseGenerator._heightMultiplier);
                mapGen.GenerateIrregularMesh(optimizedMap, mapSize);
                break;
            }

            case Optimization.None:
            {
                mapGen.GenerateRegularMesh(heightMap);
                Debug.Log("Bulding");
                break;
            }
            }
        }
        private void DrawCustomInspector()
        {
            importHeightMap    = EditorGUILayout.Toggle("Import Height Map", importHeightMap);
            optimizationMethod = (Optimization)EditorGUILayout.EnumPopup("Optimization Algorithm", optimizationMethod);

            if (importHeightMap)
            {
                ExternalHeightMapReceiver.Draw();
                SetOptimizationAlgorithmUI();
            }
            else
            {
                generationAlgorithm =
                    (GenerationAlgorithm)EditorGUILayout.EnumPopup("Generation Algorithm", generationAlgorithm);
                mapSize = Mathf.RoundToInt(EditorGUILayout.Slider("Map size", mapSize, 1, 255));
                SetGenerationAlgorithmUI();
                SetOptimizationAlgorithmUI();
            }
        }