public override void OnInspectorGUI() { serializedObject.Update(); CustomTerrain terrain = (CustomTerrain)target; //Scrollbar Starting Code Rect r = EditorGUILayout.BeginVertical(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(r.width), GUILayout.Height(r.height)); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(resetTerrain); showRandom = EditorGUILayout.Foldout(showRandom, "Random"); if (showRandom) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel); EditorGUILayout.PropertyField(randomHeightRange); if (GUILayout.Button("Random Heights")) { terrain.RandomTerrain(); } } showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights"); if (showLoadHeights) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Load Heights From Texture", EditorStyles.boldLabel); EditorGUILayout.PropertyField(heightMapImage); EditorGUILayout.PropertyField(heightMapScale); if (GUILayout.Button("Load Texture")) { terrain.LoadTexture(); } } showPerlinNoise = EditorGUILayout.Foldout(showPerlinNoise, "Single Perlin Noise"); if (showPerlinNoise) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Perlin Noise", EditorStyles.boldLabel); EditorGUILayout.Slider(perlinXScale, 0, 1, new GUIContent("X Scale")); EditorGUILayout.Slider(perlinYScale, 0, 1, new GUIContent("Y Scale")); EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000, new GUIContent("Offset X")); EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000, new GUIContent("Offset Y")); EditorGUILayout.IntSlider(perlinOctaves, 1, 10, new GUIContent("Octaves")); EditorGUILayout.Slider(perlinPersistance, 0.1f, 10, new GUIContent("Persistance")); EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale")); if (GUILayout.Button("Perlin")) { terrain.Perlin(); } } showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple Perlin Noise"); if (showMultiplePerlin) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Mulitple Perlin Noise", EditorStyles.boldLabel); perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable, serializedObject.FindProperty("perlinParameters")); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewPerlin(); } if (GUILayout.Button("-")) { terrain.RemovePerlin(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Multiple Perlin")) { terrain.MultiplePerlinTerrain(); } } showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi"); if (showVoronoi) { EditorGUILayout.IntSlider(voronoiPeaks, 1, 10, new GUIContent("Peak Count")); EditorGUILayout.Slider(voronoiFallOff, 0, 10, new GUIContent("Falloff")); EditorGUILayout.Slider(voronoiDropOff, 0, 10, new GUIContent("Dropoff")); EditorGUILayout.Slider(voronoiMinHeight, 0, 1, new GUIContent("Min Height")); EditorGUILayout.Slider(voronoiMaxHeight, 0, 1, new GUIContent("Max Height")); EditorGUILayout.PropertyField(voronoiType); if (GUILayout.Button("Voronoi")) { terrain.Voronoi(); } } showMPD = EditorGUILayout.Foldout(showMPD, "Midpoint Displacement"); if (showMPD) { EditorGUILayout.PropertyField(MPDheightMin); EditorGUILayout.PropertyField(MPDheightMax); EditorGUILayout.PropertyField(MPDheightDampenerPower); EditorGUILayout.PropertyField(MPDroughness); if (GUILayout.Button("MPD")) { terrain.MidpointDisplacement(); } } showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps"); if (showSplatMaps) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Splat Maps", EditorStyles.boldLabel); /*EditorGUILayout.Slider(splatOffset, 0, 0.1f, new GUIContent("Offset")); * EditorGUILayout.Slider(splatNoiseXScale, 0.001f, 1, new GUIContent("Noise X Scale")); * EditorGUILayout.Slider(splatNoiseYScale, 0.001f, 1, new GUIContent("Noise Y Scale")); * EditorGUILayout.Slider(splatNoiseScaler, 0, 1, new GUIContent("Noise Scaler"));*/ splatMapTable = GUITableLayout.DrawTable(splatMapTable, serializedObject.FindProperty("splatHeights")); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewSplatHeight(); } if (GUILayout.Button("-")) { terrain.RemoveSplatHeight(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply SplatMaps")) { terrain.SplatMaps(); } } showVeg = EditorGUILayout.Foldout(showVeg, "Vegetation"); if (showVeg) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Vegetation", EditorStyles.boldLabel); EditorGUILayout.IntSlider(maxTrees, 0, 10000, new GUIContent("Maximum Trees")); EditorGUILayout.IntSlider(treeSpacing, 2, 20, new GUIContent("Trees Spacing")); vegMapTable = GUITableLayout.DrawTable(vegMapTable, serializedObject.FindProperty("vegetation")); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewVegetaion(); } if (GUILayout.Button("-")) { terrain.RemoveVegetaion(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Vegetation")) { terrain.PlantVegetaion(); } } showDetail = EditorGUILayout.Foldout(showDetail, "Details"); if (showDetail) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Detail", EditorStyles.boldLabel); EditorGUILayout.IntSlider(maxDetails, 0, 10000, new GUIContent("Maximum Details")); EditorGUILayout.IntSlider(detailSpacing, 1, 20, new GUIContent("Detail Spacing")); detailMapTable = GUITableLayout.DrawTable(detailMapTable, serializedObject.FindProperty("details")); terrain.GetComponent <Terrain>().detailObjectDistance = maxDetails.intValue; GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewDetails(); } if (GUILayout.Button("-")) { terrain.RemoveDetails(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Details")) { terrain.AddDetails(); } } showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth Terrain"); if (showSmooth) { EditorGUILayout.IntSlider(smoothAmount, 1, 10, new GUIContent("smoothAmount")); if (GUILayout.Button("Smooth")) { terrain.SmoothTerrain(); } } EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); if (GUILayout.Button("Reset Terrain")) { terrain.ResetTerrain(); } // Display Height Map showHeightMap = EditorGUILayout.Foldout(showHeightMap, "Height Map"); if (showHeightMap) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); int hmtSize = (int)(EditorGUIUtility.currentViewWidth - 100); GUILayout.Label(hmTexture, GUILayout.Width(hmtSize), GUILayout.Height(hmtSize)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Refresh", GUILayout.Width(hmtSize))) { float[,] heightMap = terrain.terrainData.GetHeights(0, 0, terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight); for (int y = 0; y < terrain.terrainData.heightmapHeight; ++y) { for (int x = 0; x < terrain.terrainData.heightmapWidth; ++x) { hmTexture.SetPixel(x, y, new Color(heightMap[x, y], heightMap[x, y], heightMap[x, y], 1)); } } hmTexture.Apply(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } //Scrollbar ending code EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { serializedObject.Update(); CustomTerrain terrain = (CustomTerrain)target; Rect r = EditorGUILayout.BeginVertical(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(r.width), GUILayout.Height(r.height)); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(resetTerrain); showRandom = EditorGUILayout.Foldout(showRandom, "Random"); if (showRandom) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel); EditorGUILayout.PropertyField(randomHeightRange); if (GUILayout.Button("RandomHeights")) { terrain.RandomTerrain(); } } showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights"); if (showLoadHeights) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Load Heights From Texture", EditorStyles.boldLabel); EditorGUILayout.PropertyField(heightMapImage); EditorGUILayout.PropertyField(heightMapScale); if (GUILayout.Button("Load Texture")) { terrain.LoadTexture(); } } showPerlinNoise = EditorGUILayout.Foldout(showPerlinNoise, "Perlin Noise"); if (showPerlinNoise) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Perlin Noise", EditorStyles.boldLabel); EditorGUILayout.Slider(perlinXScale, 0, 1, new GUIContent("perlinXScale")); EditorGUILayout.Slider(perlinYScale, 0, 1, new GUIContent("perlinYScale")); EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000, new GUIContent("perlinOffsetY")); EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000, new GUIContent("perlinOffsetY")); EditorGUILayout.IntSlider(perlinOctaves, 0, 10, new GUIContent("Octaves")); EditorGUILayout.Slider(perlinPersistance, 0.1f, 10, new GUIContent("Persistance")); EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale")); if (GUILayout.Button("Perlin")) { terrain.Perlin(); } } showMultiplePerlins = EditorGUILayout.Foldout(showMultiplePerlins, "Mulitple Perlin Noise"); if (showMultiplePerlins) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Mulitple Perlin Niose", EditorStyles.boldLabel); perlinParametersTable = GUITableLayout.DrawTable(perlinParametersTable, perlinParameters); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewPerlin(); } if (GUILayout.Button("-")) { terrain.RemovePerlin(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Mutiple Perlin")) { terrain.MultiplePerlinTerrain(); } } showWater = EditorGUILayout.Foldout(showWater, "showWater"); if (showWater) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Water", EditorStyles.boldLabel); EditorGUILayout.Slider(WaterHeight, 0, 1, new GUIContent("Water Height")); EditorGUILayout.PropertyField(waterGo); if (GUILayout.Button("Add Water")) { terrain.AddWater(); } GUILayout.Label("Shore Line Material", EditorStyles.boldLabel); EditorGUILayout.PropertyField(ShoreFoam); if (GUILayout.Button("Add Shoreline")) { terrain.AddShoreline(); } } showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi"); if (showVoronoi) { EditorGUILayout.IntSlider(voronoipeakCount, 1, 10, new GUIContent("Peak Count")); EditorGUILayout.Slider(voronoifallOff, 0, 10, new GUIContent("fall Off")); EditorGUILayout.Slider(voronoidropOff, 0, 10, new GUIContent("drop Off")); EditorGUILayout.Slider(voronoimaxHeight, 0, 1, new GUIContent("max Height")); EditorGUILayout.Slider(voronoimaxWidth, 0, 1, new GUIContent("max Width")); EditorGUILayout.PropertyField(voronoiType); if (GUILayout.Button("Voronoi")) { terrain.Voronoi(); } } midPointShow = EditorGUILayout.Foldout(midPointShow, "Midpoint Displacemnet"); if (midPointShow) { EditorGUILayout.PropertyField(midPointHeightMin); EditorGUILayout.PropertyField(midPointHeightMax); EditorGUILayout.PropertyField(midPointRoughness); EditorGUILayout.PropertyField(midPointDampener); if (GUILayout.Button("MPD")) { terrain.MidPointDisplacement(); } } showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth"); if (showSmooth) { EditorGUILayout.IntSlider(smoothCount, 0, 10, new GUIContent("Smooth Count")); if (GUILayout.Button("Smooth")) { terrain.Smooth(); } } showSplatMap = EditorGUILayout.Foldout(showSplatMap, "Splat Map"); if (showSplatMap) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Splat Map", EditorStyles.boldLabel); GUILayout.Label("Max Height Of Terrain", EditorStyles.boldLabel); EditorGUILayout.FloatField(HeightestPiontInTerrian); EditorGUILayout.FloatField(LowestPointInTerrain); EditorGUILayout.Slider(splatOffset, 0, .1f, new GUIContent("Offset")); EditorGUILayout.Slider(splatNoiseXscale, 0.001f, 1, new GUIContent("Noise X scale")); EditorGUILayout.Slider(splatNoiseYscale, 0.001f, 1, new GUIContent("Noise Y scale")); EditorGUILayout.Slider(splatNoisescaler, 0, 1, new GUIContent("Noise scaler")); splatMapTable = GUITableLayout.DrawTable(splatMapTable, serializedObject.FindProperty("splatHeights")); //splatMapTable = GUITableLayout.DrawTable(splatMapTable, splatHeights); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewSplatHeights(); } if (GUILayout.Button("-")) { terrain.RemoveSplatHeight(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Splatmaps")) { terrain.SplatMaps(); } } showDetail = EditorGUILayout.Foldout(showDetail, "Detail"); if (showDetail) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Detail", EditorStyles.boldLabel); EditorGUILayout.IntSlider(maxDetails, 0, 10000, new GUIContent("Maximum Details")); EditorGUILayout.IntSlider(detailsSpacing, 1, 20, new GUIContent("Detail Spacing")); detailMapTable = GUITableLayout.DrawTable(detailMapTable, serializedObject.FindProperty("details")); terrain.GetComponent <Terrain>().detailObjectDistance = maxDetails.intValue; GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewDetails(); } if (GUILayout.Button("-")) { terrain.RemoveDetails(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Details")) { terrain.AddDetails(); } } showVegetation = EditorGUILayout.Foldout(showVegetation, "Vegetation"); if (showVegetation) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Vegetation", EditorStyles.boldLabel); EditorGUILayout.IntSlider(maxTrees, 0, 10000, new GUIContent("maximum Trees")); EditorGUILayout.IntSlider(treeSpacing, 2, 20, new GUIContent("Trees Spacing")); vegetationTable = GUITableLayout.DrawTable(vegetationTable, serializedObject.FindProperty("vegetation")); //splatMapTable = GUITableLayout.DrawTable(splatMapTable, splatHeights); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewVegetation(); } if (GUILayout.Button("-")) { terrain.RemoveVegetations(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Vegetations")) { terrain.Vegetation(); } } showHeights = EditorGUILayout.Foldout(showHeights, "Height Map"); if (showHeights) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); int hmtSize = (int)(EditorGUIUtility.currentViewWidth - 100); GUILayout.Label(hmTexture, GUILayout.Width(hmtSize), GUILayout.Height(hmtSize)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Refresh", GUILayout.Width(hmtSize))) { float[,] heightMap = terrain.terrainData.GetHeights(0, 0, terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight); for (int y = 0; y < terrain.terrainData.heightmapHeight; y++) { for (int x = 0; x < terrain.terrainData.heightmapWidth; x++) { hmTexture.SetPixel(x, y, new Color(heightMap[x, y], heightMap[x, y], heightMap[x, y], 1)); if (heightMap[x, y] > HeightestPiontInTerrian) { HeightestPiontInTerrian = heightMap[x, y]; } if (heightMap[x, y] < LowestPointInTerrain) { LowestPointInTerrain = heightMap[x, y]; } } } hmTexture.Apply(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); if (GUILayout.Button("Reset")) { terrain.ResetTerrain(); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); }
//The GUI Loop, it gets update public override void OnInspectorGUI() { serializedObject.Update(); //Begin CustomTerrain terrain = (CustomTerrain)target; //Reference for our SCRIPT //CheckBox For resetTerrain EditorGUILayout.PropertyField(resetTerrainCheckBox); //Foldout on GUI showRandom = EditorGUILayout.Foldout(showRandom, "Random Heights"); if (showRandom)//A foldout need to be followed by a if statement { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel); EditorGUILayout.PropertyField(randomHeightRange); //!! link GUI values to our variable if (GUILayout.Button("Random Heights")) { terrain.RandomTerrain();//Method from our customTerrain Script to update our terrain. } } //Foldout PerlinNoise showPerlinNoise = EditorGUILayout.Foldout(showPerlinNoise, "Generate Perlin Noise"); if (showPerlinNoise)//A foldout need to be followed by a if statement { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Randomize a new Perlin Noise", EditorStyles.boldLabel); EditorGUILayout.Slider(perlinXScale, 0, 1, new GUIContent("X Scale"));//value,min,max EditorGUILayout.Slider(perlinYScale, 0, 1, new GUIContent("Y Scale")); EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000, new GUIContent("X OffSet")); EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000, new GUIContent("Y OffSet")); EditorGUILayout.IntSlider(perlinOctaves, 0, 10, new GUIContent("Octaves")); EditorGUILayout.Slider(perlinPersistence, 0.1f, 10, new GUIContent("Persistence")); EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale")); if (GUILayout.Button("Generate Perlin")) { terrain.perlin(); } } //Foldout MultiplePerlinNoise showMultiplePerlins = EditorGUILayout.Foldout(showMultiplePerlins, "Generate Multiple Perlin"); if (showMultiplePerlins) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Multiple Perlin Noise", EditorStyles.boldLabel); perlinParametersTable = GUITableLayout.DrawTable(perlinParametersTable, serializedObject.FindProperty("perlinParameters")); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.addNewPerlin(); } if (GUILayout.Button("-")) { terrain.removeNewPerlin(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Multiple Perlin")) { terrain.MultiplePerlin(); } } //Foldout to HeightMap showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights"); if (showLoadHeights)//A foldout need to be followed by a if statement { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Load Heights From Texture", EditorStyles.boldLabel); EditorGUILayout.PropertyField(heightMapImage); EditorGUILayout.PropertyField(heightMapScale); if (GUILayout.Button("Load Texture")) { terrain.LoadTexture(); } } //Voronoi showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi"); if (showVoronoi) { GUILayout.Label("Generate Voronoi Peaks", EditorStyles.boldLabel); EditorGUILayout.IntSlider(VoronoiPeakCount, 1, 10, new GUIContent("Peak count")); EditorGUILayout.Slider(VoronoiFallOff, 0.1f, 10, new GUIContent("Falloff")); EditorGUILayout.Slider(VoronoiDropOff, 0.1f, 10, new GUIContent("DropOff")); EditorGUILayout.Slider(VoronoiminHeight, 0.0f, 1f, new GUIContent("Min Height")); EditorGUILayout.Slider(VoronoiMaxHeight, 0.0f, 1f, new GUIContent("Max Height")); EditorGUILayout.PropertyField(VoronoiType); if (GUILayout.Button("Voronoi")) { terrain.voronoi(); } } //MPD showMPD = EditorGUILayout.Foldout(showMPD, "Midpoint Displacement"); if (showMPD) { EditorGUILayout.Slider(MPDminHeight, -10, 10, new GUIContent("Min Height")); EditorGUILayout.Slider(MPDmaxHeight, -10f, 10f, new GUIContent("Max Height")); EditorGUILayout.Slider(MPDRoughness, 0f, 100, new GUIContent("Roughness")); EditorGUILayout.Slider(MPDHeightDampener, 0f, 10, new GUIContent("Dampener")); if (GUILayout.Button("MPD")) { terrain.midPointDisplacement(); } } //SplatMaps showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps"); if (showSplatMaps) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Splat Maps", EditorStyles.boldLabel); GUILayout.Space(10); splatMapTable = GUITableLayout.DrawTable(splatMapTable, serializedObject.FindProperty("splatHeightsList")); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewSplatHeight(); } if (GUILayout.Button("-")) { terrain.RemoveSplatHeight(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply SplatMaps")) { terrain.SplatMaps(); } GUILayout.Space(20); } showVegetation = EditorGUILayout.Foldout(showVegetation, "Vegetation"); if (showVegetation) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Configure Vegetation", EditorStyles.boldLabel); GUILayout.Space(10); EditorGUILayout.IntSlider(maximumTrees, 1, 10000, new GUIContent("Maximum Trees")); EditorGUILayout.IntSlider(treeSpacing, 1, 25, new GUIContent("Trees Spacing")); GUILayout.Space(10); vegetations = GUITableLayout.DrawTable(vegetations, serializedObject.FindProperty("vegetations")); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddVegetation(); } if (GUILayout.Button("-")) { terrain.RemoveVegetation(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Vegetation")) { terrain.applyVegetation(); } } //Details showDetail = EditorGUILayout.Foldout(showDetail, "Details"); if (showDetail) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Detail", EditorStyles.boldLabel); EditorGUILayout.IntSlider(maxDetails, 0, 10000, new GUIContent("Maximum Details")); EditorGUILayout.IntSlider(detailSpacing, 1, 20, new GUIContent("Detail Spacing")); detailMapTable = GUITableLayout.DrawTable(detailMapTable, serializedObject.FindProperty("details")); terrain.GetComponent <Terrain>().detailObjectDistance = maxDetails.intValue; GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewDetails(); } if (GUILayout.Button("-")) { terrain.RemoveDetails(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Details")) { terrain.AddDetails(); } } showWater = EditorGUILayout.Foldout(showWater, "Water"); if (showWater) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Water", EditorStyles.boldLabel); EditorGUILayout.Slider(waterHeight, 0, 1, new GUIContent("Water Height")); EditorGUILayout.PropertyField(waterGO); if (GUILayout.Button("Add Water")) { terrain.AddWater(); } EditorGUILayout.PropertyField(shoreLineMaterial); if (GUILayout.Button("Add Shoreline")) { terrain.DrawShoreline(); } } //Erosion showErosion = EditorGUILayout.Foldout(showErosion, "Erosion"); if (showErosion) { EditorGUILayout.PropertyField(erosionType); EditorGUILayout.Slider(erosionStrength, 0f, 1f, new GUIContent("Erosion Strength")); EditorGUILayout.IntSlider(droplets, 0, 500, new GUIContent("Droplets Count")); EditorGUILayout.Slider(solubility, 0.001f, 1f, new GUIContent("Solubility")); EditorGUILayout.IntSlider(springsPerRiver, 0, 20, new GUIContent("Springs Per River")); EditorGUILayout.IntSlider(erosionSmoothAmount, 0, 10, new GUIContent("Smooth Amount")); EditorGUILayout.Slider(erosionAmount, 0.001f, 1f, new GUIContent("Erosion Amount")); if (GUILayout.Button("Erode")) { terrain.Erode(); } } //SmoothButton showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth"); if (showSmooth) { EditorGUILayout.PropertyField(smoothAmount); if (GUILayout.Button("Smooth")) { terrain.Smooth(); } } //resetButton EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); if (GUILayout.Button("Reset Terrain")) { terrain.resetTerrain(); } //Height Map showHeightMap = EditorGUILayout.Foldout(showHeightMap, "Height Map"); if (showHeightMap) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); int hmtSize = (int)(EditorGUIUtility.currentViewWidth - 100); GUILayout.Label(hmTexture, GUILayout.Width(hmtSize), GUILayout.Height(hmtSize)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Refresh", GUILayout.Width(hmtSize))) { float[,] heightMap = terrain.terrainData.GetHeights(0, 0, terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight); for (int y = 0; y < terrain.terrainData.heightmapWidth; y++) { for (int x = 0; x < terrain.terrainData.heightmapHeight; x++) { hmTexture.SetPixel(x, y, new Color(heightMap[x, y], heightMap[x, y], heightMap[x, y], 1)); } } hmTexture.Apply(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Save", GUILayout.Width(hmtSize))) { byte[] bytes = hmTexture.EncodeToPNG(); System.IO.Directory.CreateDirectory(Application.dataPath + "/SavedTextures"); File.WriteAllBytes(Application.dataPath + "/SavedTextures/" + "MyTexture" + ".png", bytes); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } serializedObject.ApplyModifiedProperties(); // END }
public override void OnInspectorGUI() { serializedObject.Update(); CustomTerrain terrain = (CustomTerrain)target; //ScrollBar Starting code Rect r = EditorGUILayout.BeginVertical(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(r.width), GUILayout.Height(r.height)); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(resetTerrain); showRandom = EditorGUILayout.Foldout(showRandom, "Random"); //Items included in the foldout show Random if (showRandom) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); // Creates Break between items GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel); // Text label EditorGUILayout.PropertyField(randomHeightRange); //SerializedProperty to be edited if (GUILayout.Button("Random Heights")) //Generates Button { terrain.RandomTerrain(); //If button pressed will execute code } } showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights"); // Items included in the foldout for setting terrain from image. if (showLoadHeights) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Load Heights From Texture", EditorStyles.boldLabel); EditorGUILayout.PropertyField(heightMapImage); EditorGUILayout.PropertyField(heightMapScale); if (GUILayout.Button("Load Texture")) { terrain.LoadTexture(); } } showPerlinNoise = EditorGUILayout.Foldout(showPerlinNoise, "Single Perlin Noise"); // Items included in the foldout for generating terrain from 2D Perlin noise if (showPerlinNoise) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("PerlinNoise", EditorStyles.boldLabel); EditorGUILayout.Slider(perlinXScale, 0, 1, new GUIContent("X Scale")); EditorGUILayout.Slider(perlinYScale, 0, 1, new GUIContent("Y Scale")); EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000, new GUIContent("Offset X")); EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000, new GUIContent("Offset Y")); EditorGUILayout.IntSlider(perlinOctaves, 1, 10, new GUIContent("Octaves")); EditorGUILayout.Slider(perlinPersistance, 1, 10, new GUIContent("Persistence")); EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale")); if (GUILayout.Button("Perlin")) { terrain.Perlin(); } } showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple Perlin Noise"); // Items included in the foldout for generating terrain with multiple Perlin noises; if (showMultiplePerlin) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Multiple Perlin Noise", EditorStyles.boldLabel); perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable, perlinParameters); // creates a table which stores each perlin noise GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewPerlin(); } if (GUILayout.Button("-")) { terrain.RemovePerlin(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Multiple Perlin")) { terrain.MultiplePerlinTerrain(); } } showVoroni = EditorGUILayout.Foldout(showVoroni, "Voronoi"); // Items included in the foldout for generating a Voronoi mountain on the terrain if (showVoroni) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Voronoi", EditorStyles.boldLabel); EditorGUILayout.IntSlider(voronoiPeakCount, 1, 10, new GUIContent("Peak Count")); EditorGUILayout.Slider(voronoiFallOff, 0, 10, new GUIContent("Fall off")); EditorGUILayout.Slider(voronoiDropOff, 0, 10, new GUIContent("Drop off")); EditorGUILayout.Slider(voronoiMinHeight, 0, 1, new GUIContent("Min Height")); EditorGUILayout.Slider(voronoiMaxHeight, 0, 1, new GUIContent("Max Height")); EditorGUILayout.PropertyField(voronoiType); if (GUILayout.Button("Voronoi")) { terrain.Voronoi(); } } showMidPointDisplacement = EditorGUILayout.Foldout(showMidPointDisplacement, "Mid Point Displacement"); // Items included in the foldout for generating a Mid point displacement mountain on the terrain if (showMidPointDisplacement) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("MidPoint Displacement", EditorStyles.boldLabel); EditorGUILayout.PropertyField(MPHeightMin); EditorGUILayout.PropertyField(MPHeightMax); EditorGUILayout.PropertyField(MPHeightDampenerPower); EditorGUILayout.PropertyField(MPRoughness); if (GUILayout.Button("Mid Point Displacement")) { terrain.MidPointDisplacement(); } } showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth Terrain"); // Items included in the foldout for generating Smoother terrain if (showSmooth) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Smooth Terrain", EditorStyles.boldLabel); EditorGUILayout.IntSlider(SmoothAmount, 1, 10, new GUIContent("Smooth Amount")); if (GUILayout.Button("Smooth")) { terrain.Smooth(); } } showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps"); // Items included in the foldout for generating SplatMap Textures for terrain if (showSplatMaps) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Splat Map", EditorStyles.boldLabel); splatMapTable = GUITableLayout.DrawTable(splatMapTable, splatHeights); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewSplatHeight(); } if (GUILayout.Button("-")) { terrain.RemoveSplatHeight(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply SplatMaps")) { terrain.SplatMaps(); } } showHeights = EditorGUILayout.Foldout(showHeights, "Height Map"); //Items included in the foldout for generating a height map of the current terrain. if (showHeights) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Current Height Map", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); int hmtSize = (int)(EditorGUIUtility.currentViewWidth - 100); GUILayout.Label(hmTexture, GUILayout.Width(hmtSize), GUILayout.Height(hmtSize)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Refresh", GUILayout.Width(hmtSize))) { float[,] heightMap = terrain.terrainData.GetHeights(0, 0, terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight); for (int y = 0; y < terrain.terrainData.heightmapHeight; y++) { for (int x = 0; x < terrain.terrainData.heightmapWidth; x++) { hmTexture.SetPixel(x, y, new Color(heightMap[x, y], heightMap[x, y], heightMap[x, y], 1)); } } hmTexture.Apply(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } showVegetation = EditorGUILayout.Foldout(showVegetation, "Vegetation"); //Items included in the foldout for generating the tree vegetation on the terrain if (showVegetation) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Vegetation", EditorStyles.boldLabel); EditorGUILayout.IntSlider(maxTrees, 0, 10000, new GUIContent("Maximum Trees")); EditorGUILayout.IntSlider(treeSpacing, 2, 20, new GUIContent("Tree Spacing")); vegetationTable = GUITableLayout.DrawTable(vegetationTable, vegatation); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewVegetation(); } if (GUILayout.Button("-")) { terrain.RemoveVegetation(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Vegetation")) { terrain.plantVegetation(); } } showDetail = EditorGUILayout.Foldout(showDetail, "Detail"); //Items included in the foldout for generating the details (e.g. grass) on the terrain if (showDetail) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Detail", EditorStyles.boldLabel); EditorGUILayout.IntSlider(maxDetails, 0, 10000, new GUIContent("Max Details")); EditorGUILayout.IntSlider(detailSpacing, 2, 20, new GUIContent("Detail Spacing")); DetailTable = GUITableLayout.DrawTable(DetailTable, details); terrain.GetComponent <Terrain>().detailObjectDistance = maxDetails.intValue; GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewDetails(); } if (GUILayout.Button("-")) { terrain.RemoveDetails(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Vegetation")) { terrain.AddDetails(); } } //Items included in the foldout for generating Water onto the map. showWater = EditorGUILayout.Foldout(showWater, "Water"); if (showWater) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Water", EditorStyles.boldLabel); EditorGUILayout.Slider(waterHeight, 0, 1, new GUIContent("Water Height")); EditorGUILayout.PropertyField(waterGO); if (GUILayout.Button("Add Water")) { terrain.Addwater(); } EditorGUILayout.PropertyField(shoreMaterial); if (GUILayout.Button("Add ShoreLine")) { terrain.DrawShoreLine(); } } //Items included in the foldout for enabling different types of erosion to occur on the terrain. showEroision = EditorGUILayout.Foldout(showEroision, "Erosion"); if (showEroision) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Erosion", EditorStyles.boldLabel); EditorGUILayout.PropertyField(ErosionType); EditorGUILayout.Slider(ErosionStrength, 0, 1, new GUIContent("Erosion Strength")); EditorGUILayout.Slider(erosionAmount, 0, 1, new GUIContent("Erosion Amount")); EditorGUILayout.IntSlider(Droplets, 0, 500, new GUIContent("Droplets")); EditorGUILayout.Slider(Solubility, 0.001f, 1, new GUIContent("Solubility")); EditorGUILayout.IntSlider(SpringsPerRiver, 0, 20, new GUIContent("Springs Per River")); EditorGUILayout.IntSlider(erosionSmoothAmount, 0, 10, new GUIContent("Smooth Amount")); if (GUILayout.Button("Erode")) { terrain.Erode(); } } //Items included in the foldout for generating clouds in the scene showClouds = EditorGUILayout.Foldout(showClouds, "Clouds"); if (showClouds) { EditorGUILayout.PropertyField(NumberOfClouds, new GUIContent("Number of Clouds")); EditorGUILayout.PropertyField(ParticlePerCloud, new GUIContent("Particles Per Cloud")); EditorGUILayout.PropertyField(CloudStartSize, new GUIContent("Cloud Particle Size")); EditorGUILayout.PropertyField(CloudSize, new GUIContent("Min Size")); EditorGUILayout.PropertyField(CloudMaxSize, new GUIContent("Max Size")); EditorGUILayout.PropertyField(CloudMaterial, true); EditorGUILayout.PropertyField(CloudShadowMaterial, true); EditorGUILayout.PropertyField(CloudColor, new GUIContent("Color")); EditorGUILayout.PropertyField(CloudLining, new GUIContent("Lining")); EditorGUILayout.PropertyField(MinSpeed, new GUIContent("Min Speed")); EditorGUILayout.PropertyField(MaxSpeed, new GUIContent("Max Speed")); EditorGUILayout.PropertyField(DistanceTravelled, new GUIContent("Distance Traveled")); if (GUILayout.Button("Generate Clouds")) { terrain.GenerateClouds(); } } // Creates the reset button EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); if (GUILayout.Button("Reset Terrain")) { terrain.ResetTerrain(); } //Scrollbar ending code EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { //Start serializedObject.Update(); //Start CustomTerrain terrain = (CustomTerrain)target; Rect r = EditorGUILayout.BeginVertical(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(r.width), GUILayout.Height(r.height)); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(resetTerrain); showRandom = EditorGUILayout.Foldout(showRandom, "Random"); if (showRandom) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Set Heights Between Random Values", EditorStyles.boldLabel); EditorGUILayout.PropertyField(randomHeightRange); if (GUILayout.Button("Random Heights")) { terrain.RandomTerrain(); } } showLoadHeights = EditorGUILayout.Foldout(showLoadHeights, "Load Heights"); if (showLoadHeights) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Load Heights from Texture", EditorStyles.boldLabel); EditorGUILayout.PropertyField(heightMapImage); EditorGUILayout.PropertyField(heightMapScale); if (GUILayout.Button("Load Texture")) { terrain.LoadTexture(); } } showPerlinNoise = EditorGUILayout.Foldout(showPerlinNoise, "Single Perlin Noise"); if (showPerlinNoise) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Perlin Noise Scale", EditorStyles.boldLabel); EditorGUILayout.Slider(perlinXScale, 0, 1, new GUIContent("X Scale")); EditorGUILayout.Slider(perlinYScale, 0, 1, new GUIContent("Y Scale")); EditorGUILayout.IntSlider(perlinOffsetX, 0, 10000, new GUIContent("Offset X")); EditorGUILayout.IntSlider(perlinOffsetY, 0, 10000, new GUIContent("Offset Y")); EditorGUILayout.IntSlider(perlinOctaves, 1, 10, new GUIContent("Octaves")); EditorGUILayout.Slider(perlinPersistance, 0.1f, 10, new GUIContent("Persistance")); EditorGUILayout.Slider(perlinHeightScale, 0, 1, new GUIContent("Height Scale")); if (GUILayout.Button("Run Perlin Noise")) { terrain.Perlin(); } } showMultiplePerlin = EditorGUILayout.Foldout(showMultiplePerlin, "Multiple Perlin Noise"); if (showMultiplePerlin) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Mulitple Perlin Noise", EditorStyles.boldLabel); perlinParameterTable = GUITableLayout.DrawTable(perlinParameterTable, serializedObject.FindProperty("perlinParameters")); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewPerlin(); } if (GUILayout.Button("-")) { terrain.RemovePerlin(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Multiple Perlin")) { terrain.MultiplePerlinTerrain(); } } showVoronoi = EditorGUILayout.Foldout(showVoronoi, "Voronoi"); if (showVoronoi) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Voronoi", EditorStyles.boldLabel); EditorGUILayout.IntSlider(voronoiPeaks, 1, 10, new GUIContent("Peak Count")); EditorGUILayout.Slider(voronoiFallOff, 0, 10, new GUIContent("Falloff")); EditorGUILayout.Slider(voronoiDropOff, 0, 10, new GUIContent("Dropoff")); EditorGUILayout.Slider(voronoiMinHeight, 0, 1, new GUIContent("Min Height")); EditorGUILayout.Slider(voronoiMaxHeight, 0, 1, new GUIContent("Max Height")); EditorGUILayout.PropertyField(voronoiType); if (GUILayout.Button("Voronoi")) { terrain.Voronoi(); } } showMPD = EditorGUILayout.Foldout(showMPD, "Midpoint Displacement"); if (showMPD) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Mid Point Displacement", EditorStyles.boldLabel); EditorGUILayout.PropertyField(MPDheightMin); EditorGUILayout.PropertyField(MPDheightMax); EditorGUILayout.PropertyField(MPDheightDampenerPower); EditorGUILayout.PropertyField(MPDroughness); if (GUILayout.Button("Calculate Mid Point Displacement")) { terrain.MidPointDisplacement(); } } showSmooth = EditorGUILayout.Foldout(showSmooth, "Smooth Terrain"); if (showSmooth) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Smooth Terrain", EditorStyles.boldLabel); EditorGUILayout.IntSlider(smoothAmount, 1, 10, new GUIContent("smoothAmount")); if (GUILayout.Button("Smooth Terrain")) { terrain.Smooth(); } } showSplatMaps = EditorGUILayout.Foldout(showSplatMaps, "Splat Maps"); if (showSplatMaps) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Splat Maps", EditorStyles.boldLabel); splatMapTable = GUITableLayout.DrawTable(splatMapTable, serializedObject.FindProperty("splatHeights")); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewSplatHeight(); } if (GUILayout.Button("-")) { terrain.RemoveSplatHeight(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Splatmaps")) { terrain.SplatMaps(); } } EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); showVeg = EditorGUILayout.Foldout(showVeg, "Vegetation"); if (showVeg) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Trees", EditorStyles.boldLabel); EditorGUILayout.IntSlider(maxTrees, 0, 10000, new GUIContent("Maximum Trees")); EditorGUILayout.IntSlider(treeSpacing, 2, 20, new GUIContent("Tree Spacing")); vegMapTable = GUITableLayout.DrawTable(vegMapTable, serializedObject.FindProperty("vegetation")); GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewVegetation(); } if (GUILayout.Button("-")) { terrain.RemoveVegetation(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Vegetation")) { terrain.PlantVegetation(); } } showDetails = EditorGUILayout.Foldout(showDetails, "Details"); if (showDetails) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Detail", EditorStyles.boldLabel); EditorGUILayout.IntSlider(maxDetails, 0, 10000, new GUIContent("Maximum Details")); EditorGUILayout.IntSlider(detailSpacing, 2, 20, new GUIContent("Detail Spacing")); detailMapTable = GUITableLayout.DrawTable(detailMapTable, serializedObject.FindProperty("details")); terrain.GetComponent <Terrain>().detailObjectDistance = maxDetails.intValue; GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("+")) { terrain.AddNewDetails(); } if (GUILayout.Button("-")) { terrain.RemoveDetails(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Apply Details")) { terrain.AddDetails(); } } showWater = EditorGUILayout.Foldout(showWater, "Water"); if (showWater) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Water", EditorStyles.boldLabel); EditorGUILayout.Slider(waterHeight, 0, 1, new GUIContent("Water Height")); EditorGUILayout.PropertyField(waterGameObject); if (GUILayout.Button("Add Water")) { terrain.AddWater(); } EditorGUILayout.PropertyField(shoreLineMaterial); if (GUILayout.Button("Draw Shoreline")) { terrain.DrawShoreline(); } } showErosion = EditorGUILayout.Foldout(showErosion, "Erosion"); if (showErosion) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Erosion", EditorStyles.boldLabel); EditorGUILayout.PropertyField(erosionType); EditorGUILayout.Slider(erosionStrength, 0, 1, new GUIContent("Erosion Strength")); EditorGUILayout.Slider(erosionAmount, 0, 1, new GUIContent("Erosion Amount")); EditorGUILayout.IntSlider(droplets, 0, 500, new GUIContent("Droplets")); EditorGUILayout.Slider(solubility, 0.01f, 1, new GUIContent("Solubility")); EditorGUILayout.IntSlider(springsPerRiver, 0, 20, new GUIContent("Springs Per River")); EditorGUILayout.IntSlider(erosionSmoothAmount, 0, 10, new GUIContent("Smooth Amount")); if (GUILayout.Button("Add Erosion")) { terrain.Erode(); } } showClouds = EditorGUILayout.Foldout(showClouds, "Clouds"); if (showClouds) { EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); GUILayout.Label("Clouds", EditorStyles.boldLabel); EditorGUILayout.PropertyField(numClouds, new GUIContent("Number of Clouds")); EditorGUILayout.PropertyField(particlesPerCloud, new GUIContent("Particles per Cloud")); EditorGUILayout.PropertyField(cloudStartSize, new GUIContent("Cloud Particle Size")); EditorGUILayout.PropertyField(cloudMinScale, new GUIContent("Min Size")); EditorGUILayout.PropertyField(cloudMaxScale, new GUIContent("Max Size")); EditorGUILayout.PropertyField(cloudMaterial, true); EditorGUILayout.PropertyField(cloudShadowMaterial, true); EditorGUILayout.PropertyField(cloudColor, new GUIContent("Cloud Color")); EditorGUILayout.PropertyField(cloudLining, new GUIContent("Lining Color")); EditorGUILayout.PropertyField(cloudMinSpeed, new GUIContent("Min Speed")); EditorGUILayout.PropertyField(cloudMaxSpeed, new GUIContent("Max Speed")); EditorGUILayout.PropertyField(cloudRange, new GUIContent("Distance Travelled")); if (GUILayout.Button("Add Clouds")) { terrain.GenerateClouds(); } } EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); showHeights = EditorGUILayout.Foldout(showHeights, "Height Map"); if (showHeights) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); int hmtSize = (int)(EditorGUIUtility.currentViewWidth - 100); GUILayout.Label(hmTexture, GUILayout.Width(hmtSize), GUILayout.Height(hmtSize)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Refresh", GUILayout.Width(hmtSize))) { float[,] heightMap = terrain.terrainData.GetHeights(0, 0, terrain.terrainData.heightmapResolution, terrain.terrainData.heightmapResolution); for (int y = 0; y < terrain.terrainData.alphamapHeight; y++) { for (int x = 0; x < terrain.terrainData.alphamapWidth; x++) { hmTexture.SetPixel(x, y, new Color(heightMap[x, y], heightMap[x, y], heightMap[x, y], 1)); } } hmTexture.Apply(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } if (GUILayout.Button("Reset Terrain")) { terrain.ResetTerrain(); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); //End serializedObject.ApplyModifiedProperties(); //End }