So I need to scale the trees that are placed using the Mass Tree Placement feature.
So far I have this script:
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class ResizeTrees : EditorWindow {
[MenuItem("Terrain/ResizeTrees")]
public static void ShowWindow()
{
EditorWindow.GetWindow(typeof(ResizeTrees));
}
void OnGUI()
{
GUILayout.Label ("Resize Trees", EditorStyles.boldLabel);
if (GUI.Button (new Rect(10, 10, 30,30), "Resize Trees"))
{
//List<TreeInstance> newTrees = new List<TreeInstance>(Terrain.activeTerrain.terrainData.treePrototypes);
List<TreeInstance> newTrees = new List<TreeInstance>(Terrain.activeTerrain.terrainData.treeInstances);
for (int i = 0; i < newTrees.Count; i++)
{
TreeInstance ti = Terrain.activeTerrain.terrainData.treeInstances[i];
ti.heightScale *= 2;
ti.widthScale *= 2;
// Re asign it
Terrain.activeTerrain.terrainData.treeInstances.SetValue (ti, i);
//Terrain.activeTerrain.terrainData.treeInstances[i] = ti;
}
Terrain.activeTerrain.terrainData.RefreshPrototypes ();
}
}
}
The commented out lines about assigning the tree instance back in both have the same effect, nothing changes and no errors.
Just wondering if i’m missing something obvious. Thanks in advance.