You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
923 B
C#

using UnityEngine;
/// <summary>
/// Provides methods for managing terrain groups.
/// </summary>
[System.Serializable]
public class TerrainGroup : MonoBehaviour
{
/// <summary>
/// The terrain group's identifier.
/// </summary>
public int GroupID = 0;
/// <summary>
/// Updates the grouping ID of the parented terrains.
/// </summary>
public void UpdateChildTerrains()
{
Terrain[] childTerrains = GetComponentsInChildren<Terrain>();
foreach (Terrain terrain in childTerrains)
{
GameObject existingGameObject = terrain.gameObject;
terrain.groupingID = GroupID;
}
}
/// <summary>
/// Destroys all parented terrains.
/// </summary>
public void DestroyChildTerrains()
{
Terrain[] childTerrains = GetComponentsInChildren<Terrain>();
foreach (Terrain terrain in childTerrains)
{
GameObject existingGameObject = terrain.gameObject;
DestroyImmediate(existingGameObject);
}
}
}