private void Start()
    {
        if (TerrainGranularity <= 0)
        {
            throw new ArgumentException($"Invalid '{nameof(TerrainGranularity)}'");
        }
        if (TerrainStep <= 0.0f)
        {
            throw new ArgumentException($"Invalid '{nameof(TerrainStep)}'");
        }
        if (TerrainScale <= 0.0f)
        {
            throw new ArgumentException($"Invalid '{nameof(TerrainScale)}'");
        }

        ObservedTerrain = new Terrain();
        TerrainMesh     = GetComponent <MeshFilter>().mesh;
        TerrainCollider = GetComponent <BoxCollider>();
        GetComponent <MeshRenderer>().material.SetFloat("_Scale", ObservedTerrain.Scale);
        GenerateTerrain();

        transform.position   = new Vector3(ObservedTerrain.Scale / 2.0f, ObservedTerrain.Scale / 2.0f, ObservedTerrain.Scale / 2.0f);
        transform.localScale = new Vector3(ObservedTerrain.Scale, ObservedTerrain.Scale, ObservedTerrain.Scale);

        Brush      = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        Brush.name = "CursorSphere";
        Destroy(Brush.GetComponent <SphereCollider>());
        BrushMaterial        = Brush.GetComponent <MeshRenderer>().material;
        BrushMaterial.shader = Shader.Find("Unlit/ColorBlend");
    }
 public float GetTerrainHeight(Vector3 worldPosition)
 {
     return(Terrain.SampleHeight(worldPosition));
 }