Hi. After running this code in the editor
private void ApplyStencilToTerrain(Terrain terrain, Color[] stencilPixels, int stencilWidth, int stencilHeight, Vector3 minPos, Vector3 totalSize)
{
TerrainData terrainData = terrain.terrainData;
int resolution = terrainData.heightmapResolution;
float[,] heights = terrainData.GetHeights(0, 0, resolution, resolution);
Vector3 terrainPos = terrain.transform.position;
Vector3 terrainSize = terrainData.size;
float maxHeightNormalized = maxHeight / terrainSize.y;
for (int y = 0; y < resolution; y++)
{
for (int x = 0; x < resolution; x++)
{
float normalizedX = (terrainPos.x - minPos.x + (float)x / resolution * terrainSize.x) / totalSize.x;
float normalizedY = (terrainPos.z - minPos.z + (float)y / resolution * terrainSize.z) / totalSize.z;
int stencilX = Mathf.FloorToInt(normalizedX * (stencilWidth - 1));
int stencilY = Mathf.FloorToInt(normalizedY * (stencilHeight - 1));
Color stencilColor = stencilPixels[stencilY * stencilWidth + stencilX];
heights[y, x] = (stencilColor.r > 0.5f) ? maxHeight : 0f;
}
}
terrainData.SetHeights(0, 0, heights);
}
I immediately get the editor wait dialog Application.Tick() for about 10 minutes and then it goes away. I’ve restarted editor, am not debugging and have also tried restarting PC.
I should mention the code itself completes in just a second or two.
Is there any way to determine the cause for this dialog. I assume its something in my code but I can’t see it.
Thanks