using UnityEngine; using System.Collections.Generic; public class ReduceTreeDensity : MonoBehaviour { public Terrain terrain; public int keepEveryNthTree = 2; [ContextMenu("Reduce Tree Density")] void ReduceTrees() { if (terrain == null) terrain = GetComponent(); if (terrain == null) return; var originalTrees = terrain.terrainData.treeInstances; var newTrees = new List(); for (int i = 0; i < originalTrees.Length; i++) { if (i % keepEveryNthTree == 0) newTrees.Add(originalTrees[i]); } terrain.terrainData.treeInstances = newTrees.ToArray(); Debug.Log($"Reduced trees from {originalTrees.Length} to {newTrees.Count}"); } }