public override void OnInspectorGUI() { VegetationMask = (VegetationMask)target; base.OnInspectorGUI(); EditorGUIUtility.labelWidth = 200; GUILayout.BeginVertical("box"); EditorGUILayout.HelpBox("Create the area where you want to modify the vegetation, you can remove and/or include vegetation types", MessageType.Info); GUILayout.EndVertical(); GUILayout.BeginVertical("box"); if (VegetationMask.enabled) { EditorGUILayout.LabelField("Insert Node: Ctrl-Click", LabelStyle); EditorGUILayout.LabelField("Delete Node: Ctrl-Shift-Click", LabelStyle); } else { EditorGUILayout.HelpBox("Enable mask to edit nodes", MessageType.Info); } if (VegetationMask.Nodes.Count < 4) { EditorGUILayout.HelpBox("There has to be at least 3 nodes to define the area", MessageType.Warning); } GUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUILayout.HelpBox("Select ground layers that will be used for selection when adding and moving masks. These will be used in addition to unity terrains.", MessageType.Info); VegetationMask.GroundLayerMask = LayerMaskField("Ground Layers", VegetationMask.GroundLayerMask); GUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUI.BeginChangeCheck(); VegetationMask.ShowArea = EditorGUILayout.Toggle("Show Area", VegetationMask.ShowArea); VegetationMask.ShowHandles = EditorGUILayout.Toggle("Show Handles", VegetationMask.ShowHandles); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(VegetationMask); } GUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Mask settings", LabelStyle); EditorGUI.BeginChangeCheck(); VegetationMask.MaskName = EditorGUILayout.TextField("Mask Name", VegetationMask.MaskName); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(VegetationMask); } GUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField("Global vegetation removal", LabelStyle); EditorGUILayout.HelpBox("The area within the additional perimeter range will be filtered by a noise texture. To get a 100% removal in this area set min and max range to the same distance.", MessageType.Info); VegetationMask.RemoveGrass = EditorGUILayout.Toggle("Remove Grass", VegetationMask.RemoveGrass); if (VegetationMask.RemoveGrass) { //vegetationMask.AdditionalGrassPerimiter = EditorGUILayout.Slider("Additional perimeter distance", vegetationMask.AdditionalGrassPerimiter, 0f, 40f); EditorFunctions.FloatRangeField("Additional perimeter range", ref VegetationMask.AdditionalGrassPerimiter, ref VegetationMask.AdditionalGrassPerimiterMax, 0, 40); VegetationMask.NoiseScaleGrass = EditorGUILayout.Slider("Noise scale", VegetationMask.NoiseScaleGrass, 1f, 40f); } EditorGUILayout.Space(); VegetationMask.RemovePlants = EditorGUILayout.Toggle("Remove Plants", VegetationMask.RemovePlants); if (VegetationMask.RemovePlants) { // vegetationMask.AdditionalPlantPerimiter = EditorGUILayout.Slider("Additional perimeter distance", vegetationMask.AdditionalPlantPerimiter, 0f, 40f); EditorFunctions.FloatRangeField("Additional perimeter range", ref VegetationMask.AdditionalPlantPerimiter, ref VegetationMask.AdditionalPlantPerimiterMax, 0, 40); VegetationMask.NoiseScalePlant = EditorGUILayout.Slider("Noise scale", VegetationMask.NoiseScalePlant, 1f, 40f); } EditorGUILayout.Space(); VegetationMask.RemoveTrees = EditorGUILayout.Toggle("Remove Trees", VegetationMask.RemoveTrees); if (VegetationMask.RemoveTrees) { //vegetationMask.AdditionalTreePerimiter = EditorGUILayout.Slider("Additional perimeter distance", vegetationMask.AdditionalTreePerimiter, 0f, 40f); EditorFunctions.FloatRangeField("Additional perimeter range", ref VegetationMask.AdditionalTreePerimiter, ref VegetationMask.AdditionalTreePerimiterMax, 0, 40); VegetationMask.NoiseScaleTree = EditorGUILayout.Slider("Noise scale", VegetationMask.NoiseScaleTree, 1f, 40f); } EditorGUILayout.Space(); VegetationMask.RemoveObjects = EditorGUILayout.Toggle("Remove Objects", VegetationMask.RemoveObjects); if (VegetationMask.RemoveObjects) { // vegetationMask.AdditionalObjectPerimiter = EditorGUILayout.Slider("Additional perimeter distance", vegetationMask.AdditionalObjectPerimiter, 0f, 40f); EditorFunctions.FloatRangeField("Additional perimeter range", ref VegetationMask.AdditionalObjectPerimiter, ref VegetationMask.AdditionalObjectPerimiterMax, 0, 40); VegetationMask.NoiseScaleObject = EditorGUILayout.Slider("Noise scale", VegetationMask.NoiseScaleObject, 1f, 40f); } EditorGUILayout.Space(); VegetationMask.RemoveLargeObjects = EditorGUILayout.Toggle("Remove Large Objects", VegetationMask.RemoveLargeObjects); if (VegetationMask.RemoveLargeObjects) { //vegetationMask.AdditionalLargeObjectPerimiter = EditorGUILayout.Slider("Additional perimeter distance", vegetationMask.AdditionalLargeObjectPerimiter, 0f, 40f); EditorFunctions.FloatRangeField("Additional perimeter range", ref VegetationMask.AdditionalLargeObjectPerimiter, ref VegetationMask.AdditionalLargeObjectPerimiterMax, 0, 40); VegetationMask.NoiseScaleLargeObject = EditorGUILayout.Slider("Noise scale", VegetationMask.NoiseScaleLargeObject, 1f, 40f); } GUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Localized vegetation placement", LabelStyle); VegetationMask.IncludeVegetationType = EditorGUILayout.Toggle("Include vegetation", VegetationMask.IncludeVegetationType); if (EditorGUI.EndChangeCheck()) { SetMaskDirty(); } if (VegetationMask.IncludeVegetationType) { if (GUILayout.Button("Add vegetation type")) { VegetationTypeSettings newVegetationTypeSettings = new VegetationTypeSettings(); VegetationMask.VegetationTypeList.Add(newVegetationTypeSettings); _vegetationTypeIndex = VegetationMask.VegetationTypeList.Count - 1; SetMaskDirty(); } string[] packageNameList = new string[VegetationMask.VegetationTypeList.Count]; for (int i = 0; i <= VegetationMask.VegetationTypeList.Count - 1; i++) { packageNameList[i] = (i + 1).ToString() + ". Item"; } if (VegetationMask.VegetationTypeList.Count > 0) { if (_vegetationTypeIndex > VegetationMask.VegetationTypeList.Count - 1) { _vegetationTypeIndex = VegetationMask.VegetationTypeList.Count - 1; } _vegetationTypeIndex = EditorGUILayout.Popup("Selected item", _vegetationTypeIndex, packageNameList); EditorGUI.BeginChangeCheck(); GUILayout.BeginVertical("box"); VegetationMask.VegetationTypeList[_vegetationTypeIndex].Index = (VegetationTypeIndex)EditorGUILayout.EnumPopup("Vegetation type", VegetationMask.VegetationTypeList[_vegetationTypeIndex].Index); VegetationMask.VegetationTypeList[_vegetationTypeIndex].Density = EditorGUILayout.Slider("Density", VegetationMask.VegetationTypeList[_vegetationTypeIndex].Density, 0f, 1f); VegetationMask.VegetationTypeList[_vegetationTypeIndex].Size = EditorGUILayout.Slider("Size", VegetationMask.VegetationTypeList[_vegetationTypeIndex].Size, 0f, 2f); if (GUILayout.Button("Delete selected item")) { VegetationMask.VegetationTypeList.RemoveAt(_vegetationTypeIndex); } GUILayout.EndVertical(); if (EditorGUI.EndChangeCheck()) { SetMaskDirty(); } } } GUILayout.EndVertical(); }
public override void OnInspectorGUI() { HelpTopic = "grass-patch-generator"; base.OnInspectorGUI(); _grassPatchGenerator = (GrassPatchGenerator)target; GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Patch settings", LabelStyle); EditorGUI.BeginChangeCheck(); _grassPatchGenerator.PlaneCount = EditorGUILayout.IntSlider("Plane count", _grassPatchGenerator.PlaneCount, 1, 30); _grassPatchGenerator.Size = EditorGUILayout.Slider("Size", _grassPatchGenerator.Size, 0.1f, 2f); EditorFunctions.FloatRangeField("Min/Max Scale", ref _grassPatchGenerator.MinScale, ref _grassPatchGenerator.MaxScale, 0.1f, 2f); _grassPatchGenerator.PlaneWidth = EditorGUILayout.Slider("Plane height", _grassPatchGenerator.PlaneWidth, 0f, 1f); _grassPatchGenerator.PlaneHeight = EditorGUILayout.Slider("Plane width", _grassPatchGenerator.PlaneHeight, 0f, 1f); //EditorFunctions.FloatRangeField("Min/Max Width", ref _grassPatchGenerator.PlaneWidth, // ref _grassPatchGenerator.PlaneMaxWidth, 0.1f, 2f); //EditorFunctions.FloatRangeField("Min/Max Height", ref _grassPatchGenerator.PlaneHeight, // ref _grassPatchGenerator.PlaneMaxHeight, 0.1f, 2f); //_grassPatchGenerator.PlaneWidth = EditorGUILayout.Slider("Width", _grassPatchGenerator.PlaneWidth, 0.1f, 2f); //_grassPatchGenerator.PlaneHeight = EditorGUILayout.Slider("Height", _grassPatchGenerator.PlaneHeight, 0.1f, 2f); EditorGUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Resolution", LabelStyle); _grassPatchGenerator.PlaneWidthSegments = EditorGUILayout.IntSlider("Width segments", _grassPatchGenerator.PlaneWidthSegments, 2, 8); _grassPatchGenerator.PlaneHeightSegments = EditorGUILayout.IntSlider("Height segments", _grassPatchGenerator.PlaneHeightSegments, 2, 8); EditorGUILayout.EndVertical(); //GUILayout.BeginVertical("box"); //EditorGUILayout.LabelField("View LOD of patch.", LabelStyle); //EditorGUI.BeginDisabledGroup(true); //_grassPatchGenerator.GrassPatchLod = (GrassPatchLod)EditorGUILayout.EnumPopup("Select LOD", _grassPatchGenerator.GrassPatchLod); //EditorGUI.EndDisabledGroup(); //EditorGUILayout.HelpBox("Not yet implemented", MessageType.Warning); //EditorGUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Bending", LabelStyle); _grassPatchGenerator.MinBendHeight = EditorGUILayout.Slider("Minimum bend height", _grassPatchGenerator.MinBendHeight, 0f, 1f); _grassPatchGenerator.MaxBendDistance = EditorGUILayout.Slider("Bend", _grassPatchGenerator.MaxBendDistance, 0.1f, 0.8f); _grassPatchGenerator.CurveOffset = EditorGUILayout.Slider("Curve", _grassPatchGenerator.CurveOffset, 0.1f, 0.8f); EditorGUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Mesh", LabelStyle); _grassPatchGenerator.GenerateBackside = EditorGUILayout.Toggle("Generate backside", _grassPatchGenerator.GenerateBackside); if (_grassPatchGenerator.GenerateBackside) { EditorGUILayout.HelpBox("With the Vegetation Studio custom grass shader backside is not needed. Will give unnecessary extra polygons", MessageType.Warning); } EditorGUILayout.EndVertical(); EditorGUI.BeginChangeCheck(); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Grass texture", LabelStyle); _grassPatchGenerator.GrassTexture = (Texture2D)EditorGUILayout.ObjectField(_grassPatchGenerator.GrassTexture, typeof(Texture2D), false, GUILayout.Height(64), GUILayout.Width(64)); EditorGUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Shader settings", LabelStyle); _grassPatchGenerator.ColorTint1 = EditorGUILayout.ColorField("Tint color 1", _grassPatchGenerator.ColorTint1); _grassPatchGenerator.ColorTint2 = EditorGUILayout.ColorField("Tint color 2", _grassPatchGenerator.ColorTint2); _grassPatchGenerator.RandomDarkening = EditorGUILayout.Slider("Random darkening", _grassPatchGenerator.RandomDarkening, 0f, 1f); _grassPatchGenerator.RootAmbient = EditorGUILayout.Slider("Root ambient", _grassPatchGenerator.RootAmbient, 0f, 1f); _grassPatchGenerator.TextureCutoff = EditorGUILayout.Slider("Alpha cutoff", _grassPatchGenerator.TextureCutoff, 0f, 1f); if (EditorGUI.EndChangeCheck()) { _grassPatchGenerator.UpdateTexture(); _grassPatchGenerator.GenerateGrassPatch(); EditorUtility.SetDirty(_grassPatchGenerator); } EditorGUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Ambient occlusion", LabelStyle); //EditorGUI.BeginDisabledGroup(true); _grassPatchGenerator.AmbientOcclusion = EditorGUILayout.CurveField(_grassPatchGenerator.AmbientOcclusion, Color.green, new Rect(0, 0, 1, 1), GUILayout.Height(75)); //EditorGUI.EndDisabledGroup(); EditorGUILayout.HelpBox("Horizontal: min -> max height. Vertical: bottom: no ambient -> top: max ambient", MessageType.Info); EditorGUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Wind bending", LabelStyle); _grassPatchGenerator.WindBend = EditorGUILayout.CurveField(_grassPatchGenerator.WindBend, Color.green, new Rect(0, 0, 1, 1), GUILayout.Height(75)); EditorGUILayout.HelpBox("Horizontal: min -> max height. Vertical: bottom: do not bend -> top: max bend", MessageType.Info); _grassPatchGenerator.BakePhase = EditorGUILayout.Toggle("Include phase", _grassPatchGenerator.BakePhase); _grassPatchGenerator.BakeBend = EditorGUILayout.Toggle("Include bending", _grassPatchGenerator.BakeBend); _grassPatchGenerator.BakeAo = EditorGUILayout.Toggle("Include Ambient occlusion", _grassPatchGenerator.BakeAo); EditorGUILayout.LabelField("Vertex colors", LabelStyle); _grassPatchGenerator.ShowVertexColors = EditorGUILayout.Toggle("Show vertex colors", _grassPatchGenerator.ShowVertexColors); EditorGUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Random", LabelStyle); _grassPatchGenerator.RandomSeed = EditorGUILayout.IntSlider("Seed", _grassPatchGenerator.RandomSeed, 1, 100); EditorGUILayout.EndVertical(); if (EditorGUI.EndChangeCheck()) { _grassPatchGenerator.GenerateGrassPatch(); EditorUtility.SetDirty(_grassPatchGenerator); } GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Mesh info", LabelStyle); EditorGUILayout.LabelField("Verts: " + _grassPatchGenerator.GetMeshVertexCount().ToString(), LabelStyle); EditorGUILayout.LabelField("Tris: " + _grassPatchGenerator.GetMeshTriangleCount().ToString(), LabelStyle); EditorGUILayout.EndVertical(); if (GUILayout.Button("Save prefab and add to scene")) { _grassPatchGenerator.BuildPrefab(); } if (GUILayout.Button("Save prefab with LOD and add to scene")) { _grassPatchGenerator.BuildPrefabLod(); } EditorUtility.SetDirty(_grassPatchGenerator); }