Terrain sculpting update issue

I’m having an issue with the update frequency while sculpting a terrain I created using an editor script I made.

I’m able to sculpt the terrain but it only updates when I let go of the mouse button, not in realtime like the terrain created trough the GameObject/Create Other/Terrain.

The strangest thing is that if I manually add a terrain to my scene using the built in menu item my terrain starts updating normally, even after I delete the other terrain.

So there must be a setting in Unity or the terrain component for this that I’m not aware of.

Anyone know how to fix this?

I’ll answer own question in case someone runs into the same issue:

Use this function to create terrains from editor scripts:

Terrain.CreateTerrainGameObject