Firstborn/Library/PackageCache/com.unity.terrain-tools@4.0.5/Runtime/TerrainToolbox/TerrainGroup.cs
Schaken-Mods 4ff395c862 Finished the NPC Creator tool
Finished the NPC Creator tool
2023-04-27 18:37:28 -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);
}
}
}