public void OnGUI() { layerCount = Mathf.Max(0, EditorGUILayout.IntField(new GUIContent( "Number of Tile Layers", "N layers corresponds to 4*(N^2) tiles."), layerCount)); var numTiles = Mathf.RoundToInt(GetTotalTilesFromLayers(layerCount)); GUI.color = numTiles < WarnTilesThreshold ? Color.white : Color.yellow; GUILayout.Label($"Number of tiles to generate: ~{numTiles}"); GUI.color = Color.white; seed = EditorGUILayout.TextField(new GUIContent( "Seed for Map Generator", "Different seeds produce different maps."), seed); mapBuilderSettings = (MapBuilderSettings)EditorGUILayout.ObjectField(new GUIContent( "Map Builder Settings", "Different seeds produce different maps."), mapBuilderSettings, typeof(MapBuilderSettings), false); EditorGUI.BeginDisabledGroup(mapBuilderSettings == null); if (GUILayout.Button("Generate Map")) { if (numTiles < WarnTilesThreshold || GetGenerationUserConfirmation(numTiles)) { if (mapBuilder == null || mapBuilder.InvalidMapBuilder) { SetupMapBuilder(); } var volumesPrefab = mapBuilderSettings.WorldTileVolumes == null ? null : Instantiate(mapBuilderSettings.WorldTileVolumes); UnwindCoroutine(mapBuilder.CleanAndBuild(layerCount, seed)); if (volumesPrefab != null) { UnityObjectDestroyer.Destroy(volumesPrefab); } } } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(mapBuilder == null); if (GUILayout.Button("Clear Map")) { mapBuilder.Clean(); } EditorGUI.EndDisabledGroup(); }
public void OnGUI() { layerCount = Mathf.Max(0, EditorGUILayout.IntField(new GUIContent( "Number of Tile Layers", "N layers corresponds to 4*(N^2) tiles."), layerCount)); var numTiles = Mathf.RoundToInt(GetTotalTilesFromLayers(layerCount)); GUI.color = numTiles < WarnTilesThreshold ? Color.white : Color.yellow; GUILayout.Label($"Number of tiles to generate: ~{numTiles}"); GUI.color = Color.white; seed = EditorGUILayout.TextField(new GUIContent( "Seed for Map Generator", "Different seeds produce different maps."), seed); mapTemplate = (MapTemplate)EditorGUILayout.ObjectField(new GUIContent( "Map Template", "Different seeds produce different maps."), mapTemplate, typeof(MapTemplate), false); EditorGUI.BeginDisabledGroup(mapTemplate == null); if (GUILayout.Button("Generate Map")) { if (numTiles < WarnTilesThreshold || GetGenerationUserConfirmation(numTiles)) { if (mapBuilder == null || mapBuilder.InvalidMapBuilder) { SetupMapBuilder(); } mapBuilder.CleanAndBuild(layerCount, seed).Wait(); } } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(mapBuilder == null); if (GUILayout.Button("Clear Map")) { mapBuilder.Clean(); } EditorGUI.EndDisabledGroup(); }