# Save Biome Settings

## **Opening the Window**

To open the `Save Biome Settings` window, navigate to: **`Tools > TerraForge 2 > Save Biome Settings`** in the Unity Editor menu bar.

<figure><img src="https://1503389242-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmAcFth2IS05hBefll31s%2Fuploads%2Fr8RUdcp8hkH9CNpAlwKl%2Fimage.png?alt=media&#x26;token=bd2e574d-5aaf-4aab-8c53-44baa53db3fd" alt=""><figcaption></figcaption></figure>

***

## **Interface Overview**

<figure><img src="https://1503389242-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmAcFth2IS05hBefll31s%2Fuploads%2FZT65SNhCePriBKYCplE9%2Fimage.png?alt=media&#x26;token=7bf9b8df-0d3f-4d41-9474-b047de7bf535" alt=""><figcaption></figcaption></figure>

The interface consists of several fields and buttons to configure and save your biome settings:

1. **Terrain Generator**
   * **Type:** Object Field
   * **Description:** This field allows you to assign the `TerraForge Terrain Generator` from which the biome settings will be saved. You can drag and drop the `TerraForge Terrain Generator` component from your scene or project into this field.
2. **File Name**
   * **Type:** Text Field
   * **Description:** The name of the file to save the biome settings. By default, it's set to `BiomeSettings.asset`.
3. **Save Folder**
   * **Type:** Folder Selection
   * **Description:** This field shows the folder path where the settings will be saved. You can change the save location by clicking the `Select Folder` button.
4. **Save Biome Settings**
   * **Type:** Button
   * **Description:** Clicking this button saves the biome settings from the assigned terrain generator to a file in the specified folder.

***

## **How to Use**

1. **Assign the Terrain Generator**
   * Drag and drop the `TerraForge Terrain Generator` component from your scene or project into the `Terrain Generator` field.
2. **Set the File Name**
   * Enter the desired name for your settings file in the `File Name` field. The default name is `BiomeSettings.asset`.
3. **Select the Save Folder**
   * Click the `Select Folder` button to choose a folder where the settings file will be saved. The default path is `Assets/TerraForge 2/Demo/Profiles/Biome Settings Profiles/`.
4. **Save the Settings**
   * Once all fields are set, click the `Save Biome Settings` button. If a file with the same name already exists, you'll be prompted to confirm if you want to overwrite it.

***

## Quick Script Overview

* **`ShowWindow()`**: Opens the Save Biome Settings window through the Unity menu.
* **`OnEnable()`**: Loads the last used save folder path.
* **`OnDisable()`**: Stores the current save folder path for future use.
* **`OnGUI()`**: Displays the editor interface for selecting the terrain generator, specifying the file name, and choosing the save location. It includes buttons for selecting the folder and saving the settings.
* **`SaveBiomeSettings()`**: Handles the process of saving the biome settings. It creates a `BiomeSettings` asset using data from the terrain generator, checks for existing files, and saves the asset to the specified directory. If the folder does not exist, it creates it.

***

## Additional Notes

* **File Overwrite Confirmation:** If the specified file name already exists in the save folder, you'll be prompted to confirm whether you want to overwrite the existing file.
* **Automatic Directory Creation:** If the specified save folder does not exist, it will be created automatically.
