public static void CreateTerrain()
    {
        var terrain       = CreateEmptyTerrain();
        var material      = GetMaterial();
        var configuration = ContentUtility.LoadOrCreateScriptableObject <TerrainConfiguration>(terrainConfigurationName, true);

        terrain.material             = material;
        terrain.terrainConfiguration = configuration;

        ProcessingUtility.StartProcessing(terrain.Build());
    }
    public override void OnInspectorGUI()
    {
        if (!IsReady())
        {
            InitializeEditor();
            return;
        }

        MarchingTerrain terrain = (MarchingTerrain)target;

        var configuration = (TerrainConfiguration)EditorGUILayout.ObjectField("Configuration", terrain.terrainConfiguration, typeof(TerrainConfiguration), false);

        if (terrain.terrainConfiguration != configuration)
        {
            terrain.terrainConfiguration = configuration;

            ProcessingUtility.StartProcessing(terrain.Rebuild());
        }

        if (terrain.terrainConfiguration != null)
        {
            var level = EditorGUILayout.IntField("Level", terrain.Level);

            m_width  = EditorGUILayout.IntField("Width", m_width);
            m_height = EditorGUILayout.IntField("Height", m_height);
            m_length = EditorGUILayout.IntField("Length", m_length);

            m_terrainEditorUtility.currentProps.currentToolType = (ToolType)EditorGUILayout.EnumPopup("Tool", m_terrainEditorUtility.currentProps.currentToolType);
            m_terrainEditorUtility.currentProps.brushRadius     = EditorGUILayout.Slider("Radius", m_terrainEditorUtility.currentProps.brushRadius, 1, 25);
            m_terrainEditorUtility.currentProps.brushOpacity    = EditorGUILayout.Slider("Opacity", m_terrainEditorUtility.currentProps.brushOpacity, 0.001F, 1F);

            if (m_terrainEditorUtility.currentProps.currentToolType == ToolType.Paint)
            {
                m_terrainEditorUtility.currentProps.color = EditorGUILayout.ColorField("Color", m_terrainEditorUtility.currentProps.color);
            }

            if (GUILayout.Button("Fill"))
            {
                terrain.terrainConfiguration.terrainMap.Fill(0, 0, 0, terrain.Width, terrain.Height - 1, terrain.Length, 1);
                ProcessingUtility.StartProcessing(terrain.Rebuild());
            }

            level = Mathf.Clamp(level, 1, MarchingTerrain.m_chunkSize / 2);

            if (terrain.Level != level)
            {
                terrain.Level = level;

                ProcessingUtility.StartProcessing(terrain.SetLevel(level));
            }

            if (terrain.Width != m_width || terrain.Height != m_height || terrain.Length != m_length)
            {
                if (GUILayout.Button("Resize"))
                {
                    terrain.terrainConfiguration.Resize(m_width, m_height, m_length);
                    ProcessingUtility.StartProcessing(terrain.Rebuild());
                }
            }

            if (GUILayout.Button("Rebuild"))
            {
                ProcessingUtility.StartProcessing(terrain.Build());
            }

            if (GUILayout.Button("Export"))
            {
                Mesh mesh = ProcessingUtility.StartProcessing(terrain.BuildMesh()) as Mesh;

                if (mesh != null)
                {
                    string path = EditorUtility.SaveFilePanel("Exporting mesh", "Assets", "terrain", "obj");

                    MeshExporter.MeshToFile(mesh, path);
                }
            }

            if (GUILayout.Button("Save"))
            {
                terrain.terrainConfiguration.Save();
            }
        }
    }