/// <summary> /// Removes the specified <paramref name="treeInstance"/> /// from the collection of trees who's collider to manage. /// </summary> /// <param name="treeInstance"> /// The <see cref="T:UnityEngine.TreeInstance"/> to remove. /// </param> public bool RemoveTree(TreeInstance treeInstance) { // disable collider to avoid colliding with a tree that doesn't exist for (var index = 0; index < this.infos.Count; index++) { var treeInstanceInfo = this.infos[index]; if (treeInstance.Same(treeInstanceInfo.TreeInstance)) { treeInstanceInfo.gameObject.SetActive(false); break; } } // remove the tree itself var x = treeInstance.position.x * this.data.size.x + this.terrain.transform.position.x; var z = treeInstance.position.z * this.data.size.z + this.terrain.transform.position.z; return(this.trees.Remove(x, z, treeInstance)); }