void ShowBasicSettings() { m_Settings.GroupingID = EditorGUILayout.IntField(Styles.GroupingID, m_Settings.GroupingID); m_Settings.AutoConnect = EditorGUILayout.Toggle(Styles.AllowAutoConnect, m_Settings.AutoConnect); m_Settings.DrawHeightmap = EditorGUILayout.Toggle(Styles.DrawTerrain, m_Settings.DrawHeightmap); m_Settings.DrawInstanced = EditorGUILayout.Toggle(Styles.DrawInstancedTerrain, m_Settings.DrawInstanced); m_Settings.PixelError = EditorGUILayout.Slider(Styles.PixelError, m_Settings.PixelError, 1, 200); m_Settings.BaseMapDistance = EditorGUILayout.Slider(Styles.BaseMapDist, m_Settings.BaseMapDistance, 0, kBaseMapDistMax); m_Settings.ShadowCastingMode = (ShadowCastingMode)EditorGUILayout.EnumPopup(Styles.CastShadows, m_Settings.ShadowCastingMode); #if UNITY_2019_2_OR_NEWER m_Settings.MaterialTemplate = EditorGUILayout.ObjectField("Material", m_Settings.MaterialTemplate, typeof(Material), false) as Material; #if UNITY_2021_2_OR_NEWER TerrainInspectorUtility.TerrainShaderValidationGUI(m_Settings.MaterialTemplate); #endif m_Settings.ReflectionProbeUsage = (ReflectionProbeUsage)EditorGUILayout.EnumPopup(Styles.ReflectionProbes, m_Settings.ReflectionProbeUsage); #else m_Settings.MaterialType = (Terrain.MaterialType)EditorGUILayout.EnumPopup(Styles.Material, m_Settings.MaterialType); if (m_Settings.MaterialType == Terrain.MaterialType.Custom) { m_Settings.MaterialTemplate = EditorGUILayout.ObjectField("Material", m_Settings.MaterialTemplate, typeof(Material), false) as Material; m_Settings.ReflectionProbeUsage = (ReflectionProbeUsage)EditorGUILayout.EnumPopup(Styles.ReflectionProbes, m_Settings.ReflectionProbeUsage); } if (m_Settings.MaterialType == Terrain.MaterialType.BuiltInLegacySpecular) { m_Settings.LegacySpecular = EditorGUILayout.ColorField("Specular Color", m_Settings.LegacySpecular); m_Settings.LegacyShininess = EditorGUILayout.Slider("Shininess", m_Settings.LegacyShininess, 0, 1); } #endif }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { EditorGUI.BeginChangeCheck(); commonUI.OnInspectorGUI(terrain, editContext); m_TargetStrength = EditorGUILayout.Slider(Styles.targetStrengthTxt, m_TargetStrength, 0.0f, 1.0f); if (m_TemplateMaterialEditor == null) { m_TemplateMaterialEditor = Editor.CreateEditor(terrain.materialTemplate); // fix - 1306604 } #if UNITY_2019_2_OR_NEWER // Material GUI m_ShowMaterialEditor = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.materialControls, m_ShowMaterialEditor); if (m_ShowMaterialEditor) { Editor.DrawFoldoutInspector(terrain.materialTemplate, ref m_TemplateMaterialEditor); #if UNITY_2021_2_OR_NEWER TerrainInspectorUtility.TerrainShaderValidationGUI(terrain.materialTemplate); #endif EditorGUILayout.Space(); } #endif // Layers GUI m_ShowLayerInspector = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.layerControls, m_ShowLayerInspector); if (m_ShowLayerInspector) { LayersGUI(terrain, editContext); #if UNITY_2019_2_OR_NEWER m_ShowLayerProperties = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.layerProperties, m_ShowLayerProperties); if (m_ShowLayerProperties) { if (!m_LayerRepaintFlag) { TerrainLayerUtility.ShowTerrainLayerGUI(terrain, m_SelectedTerrainLayer, ref m_SelectedTerrainLayerInspector, (m_TemplateMaterialEditor as MaterialEditor)?.customShaderGUI as ITerrainLayerCustomUI); } else { m_LayerRepaintFlag = false; // flag to skip layer property repaint when layer list modified } } #endif } if (EditorGUI.EndChangeCheck()) { TerrainToolsAnalytics.OnParameterChange(); } }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { LoadTreeIcons(terrain); // Tree picker GUI.changed = false; ShowUpgradeTreePrototypeScaleUI(terrain); GUILayout.Label(Styles.trees, EditorStyles.boldLabel); selectedTree = TerrainInspector.AspectSelectionGridImageAndText(selectedTree, m_TreeContents, 64, Styles.noTreesDefined, out var doubleClick); if (selectedTree >= m_TreeContents.Length) { selectedTree = PaintTreesTool.kInvalidTree; } if (doubleClick) { TerrainTreeContextMenus.EditTree(new MenuCommand(terrain, selectedTree)); GUIUtility.ExitGUI(); } GUILayout.BeginHorizontal(); using (new EditorGUI.DisabledScope(selectedTree == PaintTreesTool.kInvalidTree)) { if (GUILayout.Button(Styles.massPlaceTrees)) { TerrainMenus.MassPlaceTrees(); } } GUILayout.FlexibleSpace(); TerrainInspector.MenuButton(Styles.editTrees, "CONTEXT/TerrainEngineTrees", terrain, selectedTree); TerrainInspector.ShowRefreshPrototypes(); GUILayout.EndHorizontal(); GUILayout.Label(TerrainInspector.styles.settings, EditorStyles.boldLabel); // Placement distance brushSize = TerrainInspectorUtility.PowerSlider(TerrainInspector.styles.brushSize, brushSize, 1, Mathf.Min(terrain.terrainData.size.x, terrain.terrainData.size.z), 4.0f); float oldDens = (3.3f - spacing) / 3f; float newDens = TerrainInspectorUtility.ScaledSliderWithRounding(Styles.treeDensity, oldDens, 0.1f, 1.0f, 100.0f, 1.0f); // Only set spacing when value actually changes. Otherwise // it will lose precision because we're constantly doing math // back and forth with it. if (newDens != oldDens) { spacing = (1.1f - newDens) * 3f; } GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Label(Styles.treeHeight, GUILayout.Width(EditorGUIUtility.labelWidth - 6)); GUILayout.Label(Styles.treeHeightRandomLabel, GUILayout.ExpandWidth(false)); allowHeightVar = GUILayout.Toggle(allowHeightVar, Styles.treeHeightRandomToggle, GUILayout.ExpandWidth(false)); if (allowHeightVar) { EditorGUI.BeginChangeCheck(); float min = treeHeight * (1.0f - treeHeightVariation); float max = treeHeight * (1.0f + treeHeightVariation); EditorGUILayout.MinMaxSlider(ref min, ref max, 0.01f, 2.0f); if (EditorGUI.EndChangeCheck()) { treeHeight = (min + max) * 0.5f; treeHeightVariation = (max - min) / (min + max); } } else { treeHeight = EditorGUILayout.Slider(treeHeight, 0.01f, 2.0f); treeHeightVariation = 0.0f; } GUILayout.EndHorizontal(); GUILayout.Space(5); lockWidthToHeight = EditorGUILayout.Toggle(Styles.lockWidthToHeight, lockWidthToHeight); GUILayout.Space(5); using (new EditorGUI.DisabledScope(lockWidthToHeight)) { GUILayout.BeginHorizontal(); GUILayout.Label(Styles.treeWidth, GUILayout.Width(EditorGUIUtility.labelWidth - 6)); GUILayout.Label(Styles.treeWidthRandomLabel, GUILayout.ExpandWidth(false)); allowWidthVar = GUILayout.Toggle(allowWidthVar, Styles.treeWidthRandomToggle, GUILayout.ExpandWidth(false)); if (allowWidthVar) { EditorGUI.BeginChangeCheck(); float min = treeWidth * (1.0f - treeWidthVariation); float max = treeWidth * (1.0f + treeWidthVariation); EditorGUILayout.MinMaxSlider(ref min, ref max, 0.01f, 2.0f); if (EditorGUI.EndChangeCheck()) { treeWidth = (min + max) * 0.5f; treeWidthVariation = (max - min) / (min + max); } } else { treeWidth = EditorGUILayout.Slider(treeWidth, 0.01f, 2.0f); treeWidthVariation = 0.0f; } GUILayout.EndHorizontal(); } if (selectedTree == PaintTreesTool.kInvalidTree) { return; } GUILayout.Space(5); GameObject prefab = terrain.terrainData.treePrototypes[selectedTree].m_Prefab; string treePrototypeWarning; terrain.terrainData.treePrototypes[selectedTree].Validate(out treePrototypeWarning); bool isLodTreePrototype = TerrainEditorUtility.IsLODTreePrototype(prefab); using (new EditorGUI.DisabledScope(!isLodTreePrototype)) { randomRotation = EditorGUILayout.Toggle(Styles.treeRotation, randomRotation); } if (!isLodTreePrototype) { EditorGUILayout.HelpBox(Styles.treeRotationDisabled.text, MessageType.Info); } if (!string.IsNullOrEmpty(treePrototypeWarning)) { EditorGUILayout.HelpBox(treePrototypeWarning, MessageType.Warning); } // TODO: we should check if the shaders assigned to this 'tree' support _TreeInstanceColor or not.. complicated check though treeColorAdjustment = EditorGUILayout.Slider(Styles.treeColorVar, treeColorAdjustment, 0, 1); if (prefab != null) { StaticEditorFlags staticEditorFlags = GameObjectUtility.GetStaticEditorFlags(prefab); bool contributeGI = (staticEditorFlags & StaticEditorFlags.ContributeGI) != 0; using (new EditorGUI.DisabledScope(true)) // Always disabled, because we don't want to edit the prefab. contributeGI = EditorGUILayout.Toggle(Styles.treeContributeGI, contributeGI); } }