Removing colliders from terrain trees

How do you remove a tree collider from a terrain tree ? I am using an old code that detects the closest terrain tree and deletes the mesh of it if u click on it. At the end there are 2 lines to remove a collider from that tree, but that doesn’t seem to work on newer versions of Unity. What is the solution to this ? I’ve been looking for a long time and haven’t found anyone solving this problem. Maybe it’s time to leave terrain trees and have trees as game objects ?

The 2 lines that removed the collider of the terrain tree on older versions:

            float[,] heights = terrain.GetHeights(0, 0, 0, 0);
            terrain.SetHeights(0, 0, heights);

Hey @filipszyszko1234567890, I found a work around to that bit of code. Posted it on the original thread. Hope it helps.

ZSP_NNY_DeNevar reply gives a link to a solution that used to work but don’t work anymore.
I have found a solution that works with Unity 2019

TerrainCollider terrainCollider = theTerrain.GetComponent<TerrainCollider>();
terrainCollider.enabled = false;
theTerrainData.SetTreeInstances(newTreesList.ToArray(), true);
terrainCollider.enabled = true;