Topic: Do not generate buildings by conditions

If you want to not generate buildings by some condition, here's an example of how to do it.
In this example, it is forbidden to generate buildings with a height less than 30 meters.

How to use this:
Place the script in Editor folder.
If you want to change the conditions, you can do this in the OnGenerateBuilding method.
Select RWT/Do Not Generate Buildings By Conditions, click Active and generate buildings.

using System.Collections.Generic;
using System.Globalization;
using InfinityCode.RealWorldTerrain;
using InfinityCode.RealWorldTerrain.Generators;
using InfinityCode.RealWorldTerrain.OSM;
using InfinityCode.RealWorldTerrain.Windows;
using UnityEditor;
using UnityEngine;

namespace InfinityCode.RealWorldTerrainExamples
{
    /// <summary>
    /// Example of using the Real World Terrain API to not generate buildings under certain conditions.
    /// </summary>
    public class DoNotGenerateBuildingsByConditions : EditorWindow
    {
        /// <summary>
        /// Will the conditions from the script be used?
        /// </summary>
        private static bool active = false;
        
        /// <summary>
        /// Minimum building height.
        /// </summary>
        private static float minHeight = 30;
        
        /// <summary>
        /// Determines whether to generate building based on provided conditions.
        /// </summary>
        /// <param name="points">List of points for the building base.</param>
        /// <param name="way">The OSM Way data for the building.</param>
        /// <param name="nodes">The OSM Node data associated with the building.</param>
        /// <returns>True - the building should not be generated, false - it should be generated.</returns>
        private bool OnGenerateBuilding(List<Vector3> points, RealWorldTerrainOSMWay way, Dictionary<string, RealWorldTerrainOSMNode> nodes)
        {
            // Default building height.
            float baseHeight = 15;
            
            // Get the height of the building from the OSM data.
            string heightStr = way.GetTagValue("height");
            
            // If the height is not specified, try to get the number of floors.
            string levelsStr = way.GetTagValue("building:levels");
            
            // Parse the height from the string.
            RealWorldTerrainBuildingGenerator.GetHeightFromString(heightStr, ref baseHeight);
            
            // If the height is not specified, but the number of floors is specified, calculate the height based on the number of floors.
            if (string.IsNullOrEmpty(heightStr))
            {
                if (!string.IsNullOrEmpty(levelsStr))
                {
                    float h;
                    if (float.TryParse(levelsStr, NumberStyles.AllowDecimalPoint, RealWorldTerrainCultureInfo.cultureInfo, out h)) baseHeight = h * RealWorldTerrainWindow.prefs.buildingFloorHeight;
                }
                else baseHeight = RealWorldTerrainWindow.prefs.buildingFloorLimits.Random() * RealWorldTerrainWindow.prefs.buildingFloorHeight;
            }
            
            // If the height is less than the minimum, do not generate the building.
            if (baseHeight < minHeight) return true;

            // Otherwise, generate the building.
            return false;
        }

        /// <summary>
        /// Displays the GUI controls for the editor window.
        /// </summary>
        private void OnGUI()
        {
            EditorGUILayout.HelpBox("If active, buildings will not be generated under the conditions specified in the OnGenerateBuilding method.", MessageType.Info);
            
            EditorGUI.BeginChangeCheck();
            active = EditorGUILayout.Toggle("Active", active);
            if (EditorGUI.EndChangeCheck())
            {
                if (active)
                {
                    // Subscribe to the OnGenerateBuilding event.
                    RealWorldTerrainBuildingGenerator.OnGenerateBuilding -= OnGenerateBuilding;
                    RealWorldTerrainBuildingGenerator.OnGenerateBuilding += OnGenerateBuilding;
                }
                else
                {
                    // Unsubscribe from the OnGenerateBuilding event.
                    RealWorldTerrainBuildingGenerator.OnGenerateBuilding -= OnGenerateBuilding;
                }
            }
            
            minHeight = EditorGUILayout.FloatField("Min Height", minHeight);
        
            if (GUILayout.Button("Open Real World Terrain"))
            {
                RealWorldTerrainWindow.OpenWindow(RealWorldTerrainGenerateType.full);
            }
        }

        /// <summary>
        /// Opens the window.
        /// </summary>
        [MenuItem("RWT/Do Not Generate Buildings By Conditions")]
        private static void OpenWindow()
        {
            GetWindow<DoNotGenerateBuildingsByConditions>(false, "Do Not Generate Buildings By Conditions", true);
        }
    }
}
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.