Firstborn/Library/PackageCache/com.unity.terrain-tools@4.0.3/Runtime/TerrainToolbox/TerrainGroup.cs
Schaken-Mods b486678290 Library -Artifacts
Library -Artifacts
2023-03-28 12:24:16 -05:00

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);
}
}
}