public void HandleShortcutChanged(ShortcutArguments args, TKey key) { switch (args.stage) { case ShortcutStage.Begin: { if (m_OnPressedByKey.TryGetValue(key, out Action onPressed)) { m_ActiveKeys.Add(key); onPressed?.Invoke(); } break; } case ShortcutStage.End: { if (m_OnReleasedByKey.TryGetValue(key, out Action onReleased)) { onReleased?.Invoke(); m_ActiveKeys.Remove(key); TerrainToolsAnalytics.OnShortcutKeyRelease(key.ToString()); TerrainToolsAnalytics.OnParameterChange(); } break; } default: { throw new ArgumentOutOfRangeException(); } } // End of switch. }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { EditorGUI.BeginChangeCheck(); commonUI.OnInspectorGUI(terrain, editContext); m_ShowControls = TerrainToolGUIHelper.DrawHeaderFoldoutForBrush(Styles.controlHeader, m_ShowControls, Reset); if (m_ShowControls) { EditorGUILayout.BeginVertical("GroupBox"); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel(Styles.targets); m_AffectMaterials = GUILayout.Toggle(m_AffectMaterials, Styles.materials, GUI.skin.button); m_AffectHeight = GUILayout.Toggle(m_AffectHeight, Styles.heightmap, GUI.skin.button); } EditorGUILayout.EndHorizontal(); m_TwistAmount = EditorGUILayout.Slider(Styles.twistAmount, m_TwistAmount, -100.0f, 100.0f); } EditorGUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck()) { SaveSetting(); Save(true); TerrainToolsAnalytics.OnParameterChange(); } }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { if (m_HardnessNoiseSettings == null) { m_HardnessNoiseSettings = ScriptableObject.CreateInstance <NoiseSettings>(); m_HardnessNoiseSettings.Reset(); } Erosion.HydraulicErosionSettings erosionSettings = ((Erosion.HydraulicEroder)m_Eroder).m_ErosionSettings; EditorGUI.BeginChangeCheck(); commonUI.OnInspectorGUI(terrain, editContext); m_Eroder.OnInspectorGUI(terrain, editContext); commonUI.validationMessage = ValidateAndGenerateUserMessage(terrain); if (EditorGUI.EndChangeCheck()) { Save(true); TerrainToolsAnalytics.OnParameterChange(); } }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { EditorGUI.BeginChangeCheck(); commonUI.OnInspectorGUI(terrain, editContext); m_ShowControls = TerrainToolGUIHelper.DrawHeaderFoldoutForBrush(Styles.controls, m_ShowControls, terraceToolProperties.SetDefaults); if (m_ShowControls) { EditorGUILayout.BeginVertical("GroupBox"); { terraceToolProperties.m_FeatureSize = EditorGUILayout.Slider(Styles.terraceCount, terraceToolProperties.m_FeatureSize, 2.0f, 1000.0f); terraceToolProperties.m_JitterTerraceCount = EditorGUILayout.Slider(Styles.jitter, terraceToolProperties.m_JitterTerraceCount, 0.0f, 1.0f); terraceToolProperties.m_BevelAmountInterior = EditorGUILayout.Slider(Styles.cornerWeight, terraceToolProperties.m_BevelAmountInterior, 0.0f, 1.0f); } EditorGUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck()) { SaveSetting(); Save(true); TerrainToolsAnalytics.OnParameterChange(); } }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { EditorGUI.BeginChangeCheck(); commonUI.OnInspectorGUI(terrain, editContext); s_showToolControls = TerrainToolGUIHelper.DrawHeaderFoldoutForBrush(Styles.controlHeader, s_showToolControls, () => { m_TargetHeight = 0; }); if (s_showToolControls) { EditorGUILayout.BeginVertical("GroupBox"); { #if UNITY_2019_3_OR_NEWER EditorGUI.BeginChangeCheck(); m_HeightSpace = (HeightSpace)EditorGUILayout.EnumPopup(Styles.space, m_HeightSpace); if (EditorGUI.EndChangeCheck()) { if (m_HeightSpace == HeightSpace.Local) { m_TargetHeight = Mathf.Clamp(m_TargetHeight, terrain.GetPosition().y, terrain.terrainData.size.y + terrain.GetPosition().y); } } if (m_HeightSpace == HeightSpace.Local) { m_TargetHeight = EditorGUILayout.Slider(Styles.height, m_TargetHeight - terrain.GetPosition().y, 0, terrain.terrainData.size.y) + terrain.GetPosition().y; } else { m_TargetHeight = EditorGUILayout.FloatField(Styles.height, m_TargetHeight); } #else m_TargetHeight = EditorGUILayout.Slider(Styles.height, m_TargetHeight, 0, terrain.terrainData.size.y); #endif GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(Styles.flatten, GUILayout.ExpandWidth(false))) { Flatten(terrain); } if (GUILayout.Button(Styles.flattenAll, GUILayout.ExpandWidth(false))) { FlattenAll(terrain); } GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { Save(true); SaveSetting(); TerrainToolsAnalytics.OnParameterChange(); } } EditorGUILayout.EndVertical(); } }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { Init(); // brush GUI commonUI.OnInspectorGUI(terrain, editContext); EditorGUI.BeginChangeCheck(); { toolSettings.showToolSettings = TerrainToolGUIHelper.DrawHeaderFoldoutForBrush(Styles.settings, toolSettings.showToolSettings, toolSettings.SetDefaults); if (toolSettings.showToolSettings) { if (activeMesh == null) { EditorGUILayout.HelpBox(Styles.nullMeshString, MessageType.Warning); } activeMesh = EditorGUILayout.ObjectField(Styles.meshContent, activeMesh, typeof(Mesh), false) as Mesh; GUILayout.Space(8f); toolSettings.blendAmount = EditorGUILayout.Slider(Styles.blendAmount, toolSettings.blendAmount, 0, 1); GUILayout.Space(8f); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel(Styles.transformSettings); GUILayout.FlexibleSpace(); if (GUILayout.Button(Styles.resetTransformContent, GUILayout.ExpandWidth(false))) { toolSettings.rotation = Quaternion.identity; toolSettings.stampHeight = 0; toolSettings.scale = Vector3.one; } } EditorGUILayout.EndHorizontal(); toolSettings.stampHeight = EditorGUILayout.FloatField(Styles.stampHeightContent, toolSettings.stampHeight); toolSettings.scale = EditorGUILayout.Vector3Field(Styles.stampScaleContent, toolSettings.scale); toolSettings.rotation = Quaternion.Euler(EditorGUILayout.Vector3Field(Styles.stampRotationContent, toolSettings.rotation.eulerAngles)); } } if (EditorGUI.EndChangeCheck()) { SaveSettings(); Save(true); TerrainToolsAnalytics.OnParameterChange(); } }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { EditorGUI.BeginChangeCheck(); commonUI.OnInspectorGUI(terrain, editContext); commonUI.validationMessage = ValidateAndGenerateUserMessage(terrain); m_ShowControls = TerrainToolGUIHelper.DrawHeaderFoldoutForErosion(Erosion.Styles.m_ThermalErosionControls, m_ShowControls, m_Eroder.ResetTool); if (m_ShowControls) { EditorGUILayout.BeginVertical("GroupBox"); EditorGUI.BeginChangeCheck(); m_Eroder.m_MatPreset = EditorGUILayout.Popup(Erosion.Styles.m_MatPreset, m_Eroder.m_MatPreset, m_MatNames); if (EditorGUI.EndChangeCheck() && m_Eroder.m_MatPreset != 0) { m_Eroder.m_AngleOfRepose.x = m_TauValues[m_Eroder.m_MatPreset, 0]; m_Eroder.m_AngleOfRepose.y = m_TauValues[m_Eroder.m_MatPreset, 1]; } EditorGUI.indentLevel++; m_ShowAdvancedUI = TerrainToolGUIHelper.DrawSimpleFoldout(new GUIContent("Advanced"), m_ShowAdvancedUI); if (m_ShowAdvancedUI) { m_Eroder.m_ThermalIterations = EditorGUILayout.IntSlider(Erosion.Styles.m_NumIterations, m_Eroder.m_ThermalIterations, 1, 1000); m_Eroder.m_dt = EditorGUILayout.Slider(Erosion.Styles.m_TimeDelta, m_Eroder.m_dt, 0.00001f, 0.05f); EditorGUI.BeginChangeCheck(); EditorGUILayout.MinMaxSlider(Erosion.Styles.m_AngleOfRepose, ref m_Eroder.m_AngleOfRepose.x, ref m_Eroder.m_AngleOfRepose.y, 0.0f, 90.0f); if (EditorGUI.EndChangeCheck()) { m_Eroder.m_MatPreset = 0; //we changed the angle of repose, so now we should switch the UI to "Custom" } m_Eroder.m_ReposeJitter = EditorGUILayout.IntSlider(Erosion.Styles.m_AngleOfReposeJitter, (int)m_Eroder.m_ReposeJitter, 0, 100); } EditorGUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck()) { Save(true); TerrainToolsAnalytics.OnParameterChange(); } }
public virtual void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { m_ShowBrushTextures = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.brushMask, m_ShowBrushTextures); if (m_ShowBrushTextures) { editContext.ShowBrushesGUI(0, BrushGUIEditFlags.SelectAndInspect); } EditorGUI.BeginChangeCheck(); brushMaskFilterStackView.OnGUI(); m_ShowModifierControls = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.stroke, m_ShowModifierControls); if (m_ShowModifierControls) { if (m_BrushStrengthController != null) { EditorGUILayout.BeginVertical(Styles.kGroupBox); m_BrushStrengthController.OnInspectorGUI(terrain, editContext); EditorGUILayout.EndVertical(); } if (m_BrushSizeController != null) { EditorGUILayout.BeginVertical(Styles.kGroupBox); m_BrushSizeController.OnInspectorGUI(terrain, editContext); EditorGUILayout.EndVertical(); } if (m_BrushRotationController != null) { EditorGUILayout.BeginVertical(Styles.kGroupBox); m_BrushRotationController?.OnInspectorGUI(terrain, editContext); EditorGUILayout.EndVertical(); } if ((m_BrushSpacingController != null) || (m_BrushScatterController != null)) { EditorGUILayout.BeginVertical(Styles.kGroupBox); m_BrushSpacingController?.OnInspectorGUI(terrain, editContext); m_BrushScatterController?.OnInspectorGUI(terrain, editContext); EditorGUILayout.EndVertical(); } } if (EditorGUI.EndChangeCheck()) { TerrainToolsAnalytics.OnParameterChange(); } }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { EditorGUI.BeginChangeCheck(); commonUI.OnInspectorGUI(terrain, editContext); m_Eroder.OnInspectorGUI(); commonUI.validationMessage = ValidateAndGenerateUserMessage(terrain); if (EditorGUI.EndChangeCheck()) { Save(true); TerrainToolsAnalytics.OnParameterChange(); } }
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 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); EditorGUILayout.Space(); } #endif // Layers GUI UpdateLayerPalette(terrain); m_ShowLayerInspector = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.layerControls, m_ShowLayerInspector); if (m_ShowLayerInspector) { LayersGUI(); #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 } m_SelectedTerrain = terrain; if (EditorGUI.EndChangeCheck()) { TerrainToolsAnalytics.OnParameterChange(); } }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { EditorGUI.BeginChangeCheck(); commonUI.OnInspectorGUI(terrain, editContext); m_ShowControls = TerrainToolGUIHelper.DrawHeaderFoldoutForBrush(Styles.controls, m_ShowControls, Reset); if (m_ShowControls) { EditorGUILayout.BeginVertical("GroupBox"); m_direction = EditorGUILayout.Slider(Styles.direction, m_direction, -1.0f, 1.0f); m_KernelSize = EditorGUILayout.IntSlider(Styles.kernelSize, m_KernelSize, 1, terrain.terrainData.heightmapResolution / 2 - 1); EditorGUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck()) { SaveSetting(); Save(true); TerrainToolsAnalytics.OnParameterChange(); } }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { EditorGUI.BeginChangeCheck(); commonUI.OnInspectorGUI(terrain, editContext); m_ShowControls = TerrainToolGUIHelper.DrawHeaderFoldoutForBrush(Styles.controls, m_ShowControls, () => { m_FeatureSize = 25.0f; }); if (m_ShowControls) { EditorGUILayout.BeginVertical("GroupBox"); m_FeatureSize = EditorGUILayout.Slider(Styles.featureSize, m_FeatureSize, 1.0f, 100.0f); EditorGUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck()) { SaveSetting(); Save(true); TerrainToolsAnalytics.OnParameterChange(); } }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { EditorGUI.BeginChangeCheck(); commonUI.OnInspectorGUI(terrain, editContext); m_ShowControls = TerrainToolGUIHelper.DrawHeaderFoldoutForBrush(Styles.controlHeader, m_ShowControls, cloneToolProperties.SetDefaults); if (m_ShowControls) { EditorGUILayout.BeginVertical("GroupBox"); { // draw button-like toggles for choosing which terrain textures to sample EditorGUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel(Styles.cloneSourceContent); cloneToolProperties.m_PaintAlphamap = GUILayout.Toggle(cloneToolProperties.m_PaintAlphamap, Styles.cloneTextureContent, GUI.skin.button); cloneToolProperties.m_PaintHeightmap = GUILayout.Toggle(cloneToolProperties.m_PaintHeightmap, Styles.cloneHeightmapContent, GUI.skin.button); } EditorGUILayout.EndHorizontal(); cloneToolProperties.m_MovementBehavior = (MovementBehavior)EditorGUILayout.EnumPopup(Styles.cloneBehaviorContent, cloneToolProperties.m_MovementBehavior); cloneToolProperties.m_StampingOffsetFromClone = EditorGUILayout.Slider(Styles.heightOffsetContent, cloneToolProperties.m_StampingOffsetFromClone, -terrain.terrainData.size.y, terrain.terrainData.size.y); } EditorGUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck()) { // intentionally do not reset HasDoneFirstPaint here because then changing the brush mask will corrupt the clone position m_isPainting = false; Save(true); SaveSetting(); TerrainToolsAnalytics.OnParameterChange(); } }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { EditorGUI.BeginChangeCheck(); Styles styles = GetStyles(); commonUI.OnInspectorGUI(terrain, editContext); m_ShowControls = TerrainToolGUIHelper.DrawHeaderFoldoutForBrush(styles.controls, m_ShowControls, stampToolProperties.SetDefaults); if (!m_ShowControls) { return; } EditorGUI.BeginChangeCheck(); { EditorGUILayout.BeginVertical("GroupBox"); { float height = Mathf.Abs(stampToolProperties.m_StampHeight); height = EditorGUILayout.Slider(styles.height, height, 0, terrain.terrainData.size.y); stampToolProperties.stampDown = EditorGUILayout.Toggle(styles.down, stampToolProperties.stampDown); stampToolProperties.m_StampHeight = height; stampToolProperties.m_MaxBlendAdd = EditorGUILayout.Slider(styles.maxadd, stampToolProperties.m_MaxBlendAdd, 0.0f, 1.0f); } EditorGUILayout.EndVertical(); } if (EditorGUI.EndChangeCheck()) { SaveSetting(); Save(true); TerrainToolsAnalytics.OnParameterChange(); } base.OnInspectorGUI(terrain, editContext); }
public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { EditorGUI.BeginChangeCheck(); commonUI.OnInspectorGUI(terrain, editContext); m_ShowBridgeControls = TerrainToolGUIHelper.DrawHeaderFoldoutForBrush(Styles.controlHeader, m_ShowBridgeControls, bridgeToolProperties.SetDefaults); if (m_ShowBridgeControls) { //"Controls the width of the bridge over the length of the stroke" bridgeToolProperties.widthProfile = EditorGUILayout.CurveField(Styles.widthProfileContent, bridgeToolProperties.widthProfile); bridgeToolProperties.heightProfile = EditorGUILayout.CurveField(Styles.heightProfileContent, bridgeToolProperties.heightProfile); bridgeToolProperties.strengthProfile = EditorGUILayout.CurveField(Styles.strengthProfileContent, bridgeToolProperties.strengthProfile); bridgeToolProperties.jitterProfile = EditorGUILayout.CurveField(Styles.jitterProfileContent, bridgeToolProperties.jitterProfile); } if (EditorGUI.EndChangeCheck()) { SaveSetting(); Save(true); TerrainToolsAnalytics.OnParameterChange(); } }
//=================================================================================================== // // NOISE TOOL GUI // //=================================================================================================== public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext) { EditorGUI.BeginChangeCheck(); { GUILayout.Space(12); // brush GUI commonUI.OnInspectorGUI(terrain, editContext); m_showToolGUI = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.noiseToolSettings, m_showToolGUI); if (m_showToolGUI) { GUILayout.Space(12); noiseSettingsGUI.DrawPreviewTexture(256f, true); // GUILayout.Space(12); // // fill controls // EditorGUILayout.BeginHorizontal(); // { // EditorGUILayout.PrefixLabel( Styles.fillOptions ); // if (GUILayout.Button(Styles.fillSelected)) // { // FillTile(terrain); // } // if(GUILayout.Button(Styles.fillGroup)) // { // FillAllTiles(terrain); // } // } // EditorGUILayout.EndHorizontal(); // // end fill controls GUILayout.Space(12); // brush coordinate space toolbar EditorGUILayout.BeginHorizontal(); { EditorGUILayout.PrefixLabel(Styles.coordSpace); if (GUILayout.Toggle(m_toolSettings.coordSpace == CoordinateSpace.World, Styles.worldSpace, GUI.skin.button)) { m_toolSettings.coordSpace = CoordinateSpace.World; } if (GUILayout.Toggle(m_toolSettings.coordSpace == CoordinateSpace.Brush, Styles.brushSpace, GUI.skin.button)) { m_toolSettings.coordSpace = CoordinateSpace.Brush; } } EditorGUILayout.EndHorizontal(); GUILayout.Space(12); // DoSimulationControls(); DoNoiseSettingsObjectField(); noiseSettingsGUI.OnGUI(NoiseSettingsGUIFlags.Settings); GUILayout.Space(12); } } if (EditorGUI.EndChangeCheck()) { SaveSettings(); Save(true); TerrainToolsAnalytics.OnParameterChange(); } }