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();
            }
        }
        void ShowGizmoGUI()
        {
            TerrainToolboxUtilities.DrawSeperatorLine();
            bool gizmoToggle = m_Settings.EnableGizmo && ToolboxHelper.GizmoGO != null ? true : false;

            m_Settings.ShowGizmoSettings = TerrainToolGUIHelper.DrawToggleHeaderFoldout(Styles.Gizmo, m_Settings.ShowGizmoSettings, ref gizmoToggle, 0f);

            if (gizmoToggle && !ToolboxHelper.GizmoEnabled)
            {
                ToolboxHelper.ShowGizmo();
                ToolboxHelper.UpdateGizmos(m_Settings.TerrainWidth, m_Settings.TerrainHeight, m_Settings.TerrainLength, m_Settings.StartPosition, m_Settings.GroupID);
            }
            else if (!gizmoToggle && ToolboxHelper.GizmoEnabled)
            {
                ToolboxHelper.HideGizmo();
            }

            if (ToolboxHelper.GizmoEnabled && ToolboxHelper.GizmoGO != null)
            {
                if (GUI.changed)
                {
                    ToolboxHelper.UpdateGizmos(m_Settings.TerrainWidth, m_Settings.TerrainHeight, m_Settings.TerrainLength, m_Settings.StartPosition, m_Settings.GroupID);
                }
                else if (ToolboxHelper.GizmoGO.transform.hasChanged)
                {
                    Transform  gizmoTransform = ToolboxHelper.GizmoGO.transform;
                    Vector3Int gizmoScale     = Vector3Int.RoundToInt(gizmoTransform.localScale);
                    m_Settings.TerrainWidth  = gizmoScale.x;
                    m_Settings.TerrainLength = gizmoScale.z;
                    m_Settings.TerrainHeight = gizmoScale.y;
                    m_Settings.StartPosition = ToolboxHelper.GetGizmoPosition();
                }
            }



            // Update gizmo colors
            Color previousColor = m_Settings.GizmoCubeColor + m_Settings.GizmoWireColor;

            if (m_Settings.ShowGizmoSettings)
            {
                EditorGUI.BeginDisabledGroup(!m_Settings.EnableGizmo);
                EditorGUILayout.Space();
                m_Settings.GizmoCubeColor = EditorGUILayout.ColorField(Styles.CubeColor, m_Settings.GizmoCubeColor);
                m_Settings.GizmoWireColor = EditorGUILayout.ColorField(Styles.CubeWireColor, m_Settings.GizmoWireColor);
                EditorGUI.EndDisabledGroup();
            }
            m_Settings.EnableGizmo = gizmoToggle;

            if (previousColor != m_Settings.GizmoCubeColor + m_Settings.GizmoWireColor)
            {
                UnityEditor.SceneView.RepaintAll();
            }

            ToolboxHelper.SetGizmoColor(m_Settings.GizmoCubeColor, m_Settings.GizmoWireColor);
        }
Exemple #3
0
        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();
            }
        }
Exemple #4
0
        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();
            }
        }
Exemple #5
0
        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            EditorGUI.BeginChangeCheck();

            commonUI.OnInspectorGUI(terrain, editContext);
            commonUI.validationMessage = TerrainToolGUIHelper.ValidateAndGenerateSceneGUIMessage(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();
            }
        }
Exemple #6
0
        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_ShowControls = TerrainToolGUIHelper.DrawHeaderFoldoutForBrush(Styles.controls, m_ShowControls, stampToolProperties.SetDefaults);

            if (!m_ShowControls)
            {
                return;
            }

            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.BeginVertical("GroupBox");
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel(Styles.stampToolBehavior);
                    if (GUILayout.Toggle(stampToolProperties.behavior == StampToolBehavior.Min, Styles.minBehavior, GUI.skin.button))
                    {
                        stampToolProperties.behavior = StampToolBehavior.Min;
                    }

                    if (GUILayout.Toggle(stampToolProperties.behavior == StampToolBehavior.Set, Styles.setBehavior, GUI.skin.button))
                    {
                        stampToolProperties.behavior = StampToolBehavior.Set;
                    }

                    if (GUILayout.Toggle(stampToolProperties.behavior == StampToolBehavior.Max, Styles.maxBehavior, GUI.skin.button))
                    {
                        stampToolProperties.behavior = StampToolBehavior.Max;
                    }
                    EditorGUILayout.EndHorizontal();

                    stampToolProperties.stampHeight     = EditorGUILayout.Slider(Styles.height, stampToolProperties.stampHeight, -terrain.terrainData.size.y, terrain.terrainData.size.y);
                    stampToolProperties.preserveDetails = EditorGUILayout.Slider(Styles.preserveDetails, stampToolProperties.preserveDetails, 0.0f, 1.0f);
                }
                EditorGUILayout.EndVertical();
            }

            if (EditorGUI.EndChangeCheck())
            {
                SaveSetting();
                Save(true);
                TerrainToolsAnalytics.OnParameterChange();
            }

            base.OnInspectorGUI(terrain, editContext);
        }
Exemple #8
0
        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            EditorGUI.BeginChangeCheck();

            commonUI.OnInspectorGUI(terrain, editContext);
            m_Eroder.OnInspectorGUI();

            commonUI.validationMessage = TerrainToolGUIHelper.ValidateAndGenerateSceneGUIMessage(terrain);

            if (EditorGUI.EndChangeCheck())
            {
                Save(true);
                TerrainToolsAnalytics.OnParameterChange();
            }
        }
        private void TransformSettingsGUI()
        {
            EditorGUILayout.PropertyField(translation);
            EditorGUILayout.PropertyField(rotation);
            EditorGUILayout.PropertyField(scale);

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel(Styles.flipScale);
                flipScaleX.boolValue = TerrainToolGUIHelper.ToggleButton(Styles.flipScaleX, flipScaleX.boolValue);
                flipScaleY.boolValue = TerrainToolGUIHelper.ToggleButton(Styles.flipScaleY, flipScaleY.boolValue);
                flipScaleZ.boolValue = TerrainToolGUIHelper.ToggleButton(Styles.flipScaleZ, flipScaleZ.boolValue);
            }
            EditorGUILayout.EndHorizontal();
        }
        public virtual void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            m_ShowBrushTextures = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.brushMask, m_ShowBrushTextures);
            if (m_ShowBrushTextures)
            {
                editContext.ShowBrushesGUI(0, BrushGUIEditFlags.SelectAndInspect);
            }

            // Removing this for now for cleaner UI / UX. If we want to bring this back, we should build a global
            // Brush Settings dialog somewhere.s
            //s_MultipleControlShortcuts = EditorGUILayout.Toggle(Styles.multipleControls, s_MultipleControlShortcuts);

            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();
                }
            }
        }
        /// <summary>
        /// Renders the GUI for the NoiseSettings instance associated with this NoiseSettingsGUI instance.
        /// </summary>
        /// <param name="flags"> Flags specifying which portions of the GUI to draw </param>
        public void OnGUI(NoiseSettingsGUIFlags flags = NoiseSettingsGUIFlags.All)
        {
            serializedNoise.Update();

            if ((flags & NoiseSettingsGUIFlags.Preview) != 0)
            {
                DrawPreviewTexture(256f, true);
            }

            if ((flags & NoiseSettingsGUIFlags.Settings) != 0)
            {
                TerrainToolGUIHelper.DrawFoldout(transformSettings, Styles.transformSettings, TransformSettingsGUI);
                TerrainToolGUIHelper.DrawFoldout(domainSettings, Styles.domainSettings, DomainSettingsGUI);
                // TerrainToolGUIHelper.DrawFoldout(filterSettings, Styles.filterSettings, FilterSettingsGUI);
            }

            serializedNoise.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            if (!m_initialized)
            {
                LoadSettings();
                m_initialized = true;
            }

            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  = TerrainToolGUIHelper.ToggleButton(Styles.cloneTextureContent, cloneToolProperties.m_PaintAlphamap);
                        cloneToolProperties.m_PaintHeightmap = TerrainToolGUIHelper.ToggleButton(Styles.cloneHeightmapContent, cloneToolProperties.m_PaintHeightmap);
                    }
                    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())
            {
                m_isPainting        = false;
                m_HasDoneFirstPaint = false;
                Save(true);
                SaveSetting();
            }
        }
        public void OnInspectorGUI()
        {
            m_ShowControls = TerrainToolGUIHelper.DrawHeaderFoldoutForErosion(Erosion.Styles.m_WindErosionControls, m_ShowControls, ResetSettings);

            if (m_ShowControls)
            {
                EditorGUILayout.BeginVertical("GroupBox");
                m_SimulationScale.DrawInspectorGUI();
                m_WindSpeed.DrawInspectorGUI();
                //m_WindSpeedJitter = (float)EditorGUILayout.IntSlider(Erosion.Styles.m_WindSpeedJitter, (int)m_WindSpeedJitter, 0, 100);

                EditorGUI.indentLevel++;
                m_ShowAdvancedUI = TerrainToolGUIHelper.DrawSimpleFoldout(new GUIContent("Advanced"), m_ShowAdvancedUI);
                if (m_ShowAdvancedUI)
                {
                    m_dt.DrawInspectorGUI();
                    m_Iterations.DrawInspectorGUI();

                    m_SuspensionRate.DrawInspectorGUI();
                    m_DepositionRate.DrawInspectorGUI();
                    m_SlopeFactor.DrawInspectorGUI();

                    m_AdvectionVelScale.DrawInspectorGUI();
                    m_DragCoefficient.DrawInspectorGUI();
                    m_ReflectionCoefficient.DrawInspectorGUI();
                    m_DiffusionRate.DrawInspectorGUI();
                    m_AbrasivenessCoefficient.DrawInspectorGUI();

                    m_Viscosity.DrawInspectorGUI();
                    //m_DiffuseSteps = EditorGUILayout.IntSlider("Diffusion Steps", m_DiffuseSteps, 0, 20);
                    //m_ProjectionSteps = EditorGUILayout.IntSlider("Projection Steps", m_ProjectionSteps, 0, 20);
                    EditorGUI.indentLevel++;
                    m_ShowThermalUI = TerrainToolGUIHelper.DrawSimpleFoldout(new GUIContent("Thermal Smoothing"), m_ShowThermalUI, 1);
                    if (m_ShowThermalUI)
                    {
                        m_ThermalIterations = EditorGUILayout.IntSlider("# Iterations", m_ThermalIterations, 0, 100);
                        m_ThermalTimeDelta.DrawInspectorGUI();
                        m_AngleOfRepose = EditorGUILayout.Slider(Erosion.Styles.m_AngleOfRepose, m_AngleOfRepose, 0.0f, 89.0f);
                    }
                }
                EditorGUILayout.EndVertical();
            }
        }
Exemple #14
0
        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            if (!m_initialized)
            {
                LoadSettings();
                m_initialized = true;
            }

            EditorGUI.BeginChangeCheck();
            Styles styles = GetStyles();

            commonUI.OnInspectorGUI(terrain, editContext);

            m_ShowControls = TerrainToolGUIHelper.DrawHeaderFoldout(styles.controls, m_ShowControls);

            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);
            }

            base.OnInspectorGUI(terrain, editContext);
        }
Exemple #15
0
        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;
        }
Exemple #16
0
        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();
            }
        }
Exemple #17
0
        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)
        {
            if (!m_initialized)
            {
                LoadSettings();
                m_initialized = true;
            }
            EditorGUI.BeginChangeCheck();

            commonUI.OnInspectorGUI(terrain, editContext);

            s_showToolControls = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.controlHeader, s_showToolControls);

            if (s_showToolControls)
            {
                EditorGUILayout.BeginVertical("GroupBox");
                {
                    GUILayout.BeginHorizontal();
                    {
                        m_HeightWorldSpace = EditorGUILayout.Slider(Styles.height, m_HeightWorldSpace, 0, terrain.terrainData.size.y);
                        if (GUILayout.Button(Styles.flatten, GUILayout.ExpandWidth(false)))
                        {
                            Flatten(terrain);
                        }
                        if (GUILayout.Button(Styles.flattenAll, GUILayout.ExpandWidth(false)))
                        {
                            FlattenAll(terrain);
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                EditorGUILayout.EndVertical();
            }

            if (EditorGUI.EndChangeCheck())
            {
                SaveSetting();
                Save(true);
            }
        }
 void ShowOptionsGUI()
 {
     TerrainToolboxUtilities.DrawSeperatorLine();
     m_Settings.ShowOptions = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.Options, m_Settings.ShowOptions);
     ++EditorGUI.indentLevel;
     if (m_Settings.ShowOptions)
     {
         EditorGUILayout.BeginHorizontal();
         m_Settings.TerrainAssetDirectory = EditorGUILayout.TextField(Styles.TerrainDataFolderPath, m_Settings.TerrainAssetDirectory);
         if (GUILayout.Button("...", GUILayout.Width(25)))
         {
             m_Settings.TerrainAssetDirectory = EditorUtility.OpenFolderPanel("Select a folder...", m_Settings.TerrainAssetDirectory, "");
         }
         EditorGUILayout.EndHorizontal();
         m_Settings.EnableGuid = EditorGUILayout.Toggle(Styles.TerrainDataGuidEnable, m_Settings.EnableGuid);
         EditorGUILayout.BeginHorizontal();
         m_Settings.EnableClearExistingData = EditorGUILayout.Toggle(Styles.ClearExistingTerrainData, m_Settings.EnableClearExistingData);
         EditorGUILayout.LabelField(string.Format("Group ID: {0}", m_Settings.GroupID));
         EditorGUILayout.EndHorizontal();
         m_Settings.EnableLightingAutoBake = EditorGUILayout.Toggle(Styles.LightingAutobakeEnable, m_Settings.EnableLightingAutoBake);
     }
 }
Exemple #20
0
        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();
            }
        }
Exemple #21
0
        public override string DoGUI(string serializedString)
        {
            if (string.IsNullOrEmpty(serializedString))
            {
                serializedString = GetDefaultSerializedString();
            }

            // deserialize string
            StrataFractalInput strata = (StrataFractalInput)FromSerializedString(serializedString);

            // do gui here
            EditorGUILayout.Space();
            strata.strataOffset = EditorGUILayout.FloatField(Styles.strataOffset, strata.strataOffset);
            strata.strataScale  = EditorGUILayout.FloatField(Styles.strataScale, strata.strataScale);
            EditorGUILayout.Space();
            strata.octaves     = EditorGUILayout.Slider(Styles.octaves, strata.octaves, strata.octavesMinMax.x, strata.octavesMinMax.y);
            strata.amplitude   = EditorGUILayout.Slider(Styles.amplitude, strata.amplitude, strata.amplitudeMinMax.x, strata.amplitudeMinMax.y);
            strata.persistence = EditorGUILayout.Slider(Styles.persistence, strata.persistence, strata.persistenceMinMax.x, strata.persistenceMinMax.y);
            strata.frequency   = EditorGUILayout.Slider(Styles.frequency, strata.frequency, strata.frequencyMinMax.x, strata.frequencyMinMax.y);
            strata.lacunarity  = EditorGUILayout.Slider(Styles.lacunarity, strata.lacunarity, strata.lacunarityMinMax.x, strata.lacunarityMinMax.y);

            bool toggled = strata.warpEnabled;

            strata.warpExpanded = TerrainToolGUIHelper.DrawToggleHeaderFoldout(Styles.domainWarpSettings, strata.warpExpanded, ref toggled);

            if (strata.warpExpanded)
            {
                EditorGUI.indentLevel++;
                {
                    DomainWarpSettingsGUI(ref strata);
                }
                EditorGUI.indentLevel--;
            }

            strata.warpEnabled = toggled;

            return(ToSerializedString(strata));
        }
        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            if (!m_initialized)
            {
                LoadSettings();
                m_initialized = true;
            }
            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 = TerrainToolGUIHelper.ToggleButton(Styles.materials, m_AffectMaterials);
                        m_AffectHeight    = TerrainToolGUIHelper.ToggleButton(Styles.heightmap, m_AffectHeight);
                    }
                    EditorGUILayout.EndHorizontal();

                    m_TwistAmount = EditorGUILayout.Slider(Styles.twistAmount, m_TwistAmount, -100.0f, 100.0f);
                }
                EditorGUILayout.EndVertical();
            }


            if (EditorGUI.EndChangeCheck())
            {
                SaveSetting();
                Save(true);
            }
        }
Exemple #23
0
        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();
            }
        }
Exemple #24
0
        public override void OnSceneGUI(Event currentEvent, int controlId, Terrain terrain, IOnSceneGUI editContext)
        {
            RaycastHit raycastHit = editContext.raycastHit;

            base.OnSceneGUI(currentEvent, controlId, terrain, editContext);
            m_JitterHandler.frequency = m_SmoothJitterFreq.value;
            m_JitterHandler.Update();
            OnSceneEvent(raycastHit, currentEvent.isMouse, currentEvent.type == EventType.MouseDrag);

            if (m_AdjustingRotation && editContext.hitValidTerrain)
            {
                // need to compensate for higher dpi screens
                float pixelPointMultiplier = 1.0f / EditorGUIUtility.pixelsPerPoint;
                var   pos = editContext.sceneView.camera.WorldToScreenPoint(raycastHitUnderCursor.point) * pixelPointMultiplier;
                Handles.BeginGUI();
                {
                    GUI.matrix = Matrix4x4.identity;
                    var temp = TerrainToolGUIHelper.TempContent($"Rotation: {Mathf.RoundToInt(currentRotation)}°");
                    GUI.Label(new Rect(pos.x + 10 * pixelPointMultiplier, (Screen.height * pixelPointMultiplier - pos.y - 60 * pixelPointMultiplier) + EditorGUIUtility.singleLineHeight, s_SceneLabelStyle.CalcSize(temp).x, EditorGUIUtility.singleLineHeight), temp, s_SceneLabelStyle);
                }
                Handles.EndGUI();
                RequestRepaint();
            }
        }
        public void OnGUI()
        {
            // scroll view of settings
            EditorGUIUtility.hierarchyMode = true;
            TerrainToolboxUtilities.DrawSeperatorLine();
            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Load Settings From: ");
            m_SettingsMode = (SettingsMode)GUILayout.Toolbar((int)m_SettingsMode, Styles.SettingsModeToggles, Styles.ToggleButtonStyle, GUI.ToolbarButtonSize.Fixed);

            if (GUILayout.Button("Load"))
            {
                if (m_SettingsMode == SettingsMode.Default)
                {
                    ResetToDefaultSettings();
                }

                if (m_SettingsMode == SettingsMode.SelectedTerrain)
                {
                    LoadSettingsFromSelectedTerrain();
                }

                if (m_SettingsMode == SettingsMode.Preset)
                {
                    LoadPresetToSettings();
                }
            }
            EditorGUILayout.EndHorizontal();

            // Presets
            TerrainToolboxUtilities.DrawSeperatorLine();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(Styles.Preset, EditorStyles.boldLabel);
            EditorGUI.BeginChangeCheck();
            m_SelectedPreset = (TerrainSettings)EditorGUILayout.ObjectField(m_SelectedPreset, typeof(TerrainSettings), false);
            if (EditorGUI.EndChangeCheck() && m_SelectedPreset != null)
            {
                if (EditorUtility.DisplayDialog("Confirm", "Load terrain settings from selected preset?", "OK", "Cancel"))
                {
                    m_Settings = m_SelectedPreset;
                }
            }
            if (GUILayout.Button(Styles.SavePreset))
            {
                if (m_SelectedPreset == null)
                {
                    if (EditorUtility.DisplayDialog("Confirm", "No preset selected. Create a new preset?", "Continue", "Cancel"))
                    {
                        CreateNewPreset();
                    }
                }
                else
                {
                    SavePresetSettings();
                }
            }
            if (GUILayout.Button(Styles.SaveAsPreset))
            {
                CreateNewPreset();
            }
            if (GUILayout.Button(Styles.RefreshPreset))
            {
                LoadPresetToSettings();
            }
            EditorGUILayout.EndHorizontal();

            // basic settings
            TerrainToolboxUtilities.DrawSeperatorLine();
            bool basicSettingToggled = m_Settings.EnableBasicSettings;

            m_Settings.ShowBasicTerrainSettings = TerrainToolGUIHelper.DrawToggleHeaderFoldout(Styles.BasicTerrainSettings, m_Settings.ShowBasicTerrainSettings, ref basicSettingToggled, 0f);
            ++EditorGUI.indentLevel;
            if (m_Settings.ShowBasicTerrainSettings)
            {
                EditorGUI.BeginDisabledGroup(!m_Settings.EnableBasicSettings);
                ShowBasicSettings();
                EditorGUI.EndDisabledGroup();
            }
            --EditorGUI.indentLevel;
            m_Settings.EnableBasicSettings = basicSettingToggled;

            // mesh resolution settings
            TerrainToolboxUtilities.DrawSeperatorLine();
            bool meshSettingToggled = m_Settings.EnableMeshResSettings;

            m_Settings.ShowMeshResolutionSettings = TerrainToolGUIHelper.DrawToggleHeaderFoldout(Styles.MeshResolutionSettings, m_Settings.ShowMeshResolutionSettings, ref meshSettingToggled, 0f);
            ++EditorGUI.indentLevel;
            if (m_Settings.ShowMeshResolutionSettings)
            {
                EditorGUI.BeginDisabledGroup(!m_Settings.EnableMeshResSettings);
                ShowMeshResolutionSettings();
                EditorGUI.EndDisabledGroup();
            }
            --EditorGUI.indentLevel;
            m_Settings.EnableMeshResSettings = meshSettingToggled;

            // texture resolution settings
            TerrainToolboxUtilities.DrawSeperatorLine();
            bool textureSettingToggled = m_Settings.EnableTextureResSettings;

            m_Settings.ShowTextureResolutionSettings = TerrainToolGUIHelper.DrawToggleHeaderFoldout(Styles.TextureResolutionSettings, m_Settings.ShowTextureResolutionSettings, ref textureSettingToggled, 0f);
            ++EditorGUI.indentLevel;
            if (m_Settings.ShowTextureResolutionSettings)
            {
                EditorGUI.BeginDisabledGroup(!m_Settings.EnableTextureResSettings);
                ShowTextureResolutionSettings();
                EditorGUI.EndDisabledGroup();
            }
            --EditorGUI.indentLevel;
            m_Settings.EnableTextureResSettings = textureSettingToggled;

            // trees and details
            TerrainToolboxUtilities.DrawSeperatorLine();
            bool treeSettingToggled = m_Settings.EnableTreeSettings;

            m_Settings.ShowTreeAndDetailSettings = TerrainToolGUIHelper.DrawToggleHeaderFoldout(Styles.TreeAndDetailSettings, m_Settings.ShowTreeAndDetailSettings, ref treeSettingToggled, 0f);
            ++EditorGUI.indentLevel;
            if (m_Settings.ShowTreeAndDetailSettings)
            {
                EditorGUI.BeginDisabledGroup(!m_Settings.EnableTreeSettings);
                ShowTreeAndDetailSettings();
                EditorGUI.EndDisabledGroup();
            }
            --EditorGUI.indentLevel;
            m_Settings.EnableTreeSettings = treeSettingToggled;

            // grass wind
            TerrainToolboxUtilities.DrawSeperatorLine();
            bool grassSettingToggled = m_Settings.EnableWindSettings;

            m_Settings.ShowGrassWindSettings = TerrainToolGUIHelper.DrawToggleHeaderFoldout(Styles.GrassWindSettings, m_Settings.ShowGrassWindSettings, ref grassSettingToggled, 0f);
            ++EditorGUI.indentLevel;
            if (m_Settings.ShowGrassWindSettings)
            {
                EditorGUI.BeginDisabledGroup(!m_Settings.EnableWindSettings);
                ShowGrassWindSettings();
                EditorGUI.EndDisabledGroup();
            }
            --EditorGUI.indentLevel;
            m_Settings.EnableWindSettings = grassSettingToggled;

            --EditorGUI.indentLevel;
            EditorGUILayout.Space();
            EditorGUILayout.EndScrollView();

            // buttons
            TerrainToolboxUtilities.DrawSeperatorLine();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(Styles.ApplySettingsBtn, GUILayout.Height(40)))
            {
                ApplySettingsToSelectedTerrains();
            }
            if (GUILayout.Button(Styles.ApplySettingsToAllBtn, GUILayout.Height(40)))
            {
                if (EditorUtility.DisplayDialog("Confirm", "This operation will apply settings to all terrains in scene. Are you sure you want to continue?", "Continue", "Cancel"))
                {
                    ApplySettingsToAllTerrains();
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }
Exemple #26
0
        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            Init();

            // brush GUI
            brushUI.OnInspectorGUI(terrain, editContext);

            EditorGUI.BeginChangeCheck();
            {
                toolSettings.showToolSettings = TerrainToolGUIHelper.DrawHeaderFoldout(Styles.settings, toolSettings.showToolSettings);
                if (toolSettings.showToolSettings)
                {
                    toolSettings.blendAmount = EditorGUILayout.Slider(Styles.blendAmount, toolSettings.blendAmount, 0, 1);

                    if (activeMesh == null)
                    {
                        EditorGUILayout.HelpBox(Styles.nullMeshString, MessageType.Warning);
                    }

                    EditorGUILayout.BeginHorizontal();
                    {
                        activeMesh = EditorGUILayout.ObjectField(Styles.meshContent, activeMesh as Object, typeof(Mesh), false) as Mesh;

                        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.scale.x = Mathf.Max(toolSettings.scale.x, 0.02f);
                    toolSettings.scale.y = Mathf.Max(toolSettings.scale.y, 0.02f);
                    toolSettings.scale.z = Mathf.Max(toolSettings.scale.z, 0.02f);

                    toolSettings.rotation = Quaternion.Euler(EditorGUILayout.Vector3Field(Styles.stampRotationContent, toolSettings.rotation.eulerAngles));
                }
            }

            // EditorGUILayout.BeginVertical("GroupBox");
            // {
            //     GUILayout.Label( "World Bounds:" );
            //     GUILayout.Label( "Center: " + m_worldBounds.center );
            //     GUILayout.Label( "Size: " + m_worldBounds.size );
            //     GUILayout.Label( "Max: " + m_worldBounds.max );
            //     GUILayout.Label( "Min: " + m_worldBounds.min );
            // }
            // EditorGUILayout.EndVertical();

            // EditorGUILayout.BeginVertical("GroupBox");
            // {
            //     GUILayout.Label( "Ortho Camera:" );
            //     GUILayout.Label( "LookAt: " + lookAtZ );
            //     GUILayout.Label( "Near: " + nearPlane );
            //     GUILayout.Label( "Far: " + farPlane );
            //     GUILayout.Label( "Right: " + orthoRight );
            //     GUILayout.Label( "Left: " + orthoLeft );
            // }
            // EditorGUILayout.EndVertical();

            // EditorGUILayout.BeginVertical("GroupBox");
            // {
            //     GUILayout.Label( "Handle Info:" );
            //     GUILayout.Label( "Handle Pos: " + m_baseHandlePos );
            //     GUILayout.Label( "Delta height: " + m_handleHeightOffsetWS );
            //     GUILayout.Label( "Stamp height: " + toolSettings.stampHeight );
            // }
            // EditorGUILayout.EndVertical();

            // debugOrtho = TerrainToolGUIHelper.DrawHeaderFoldout( new GUIContent("Debug"), debugOrtho );
            // if( debugOrtho )
            // {
            //     orthoLeft = EditorGUILayout.FloatField( "Left", orthoLeft );
            //     orthoRight = EditorGUILayout.FloatField( "Right", orthoRight );
            //     orthoTop = EditorGUILayout.FloatField( "Top", orthoTop );
            //     orthoBottom = EditorGUILayout.FloatField( "Bottom", orthoBottom );
            //     nearPlane = EditorGUILayout.FloatField( "Near", nearPlane );
            //     farPlane = EditorGUILayout.FloatField( "Far", farPlane );
            //     lookAtZ = EditorGUILayout.FloatField( "LookAtZ", lookAtZ );
            // }

            if (EditorGUI.EndChangeCheck())
            {
                SaveSettings();
                Save(true);
            }
        }
Exemple #27
0
        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            EditorGUI.BeginChangeCheck();

            commonUI.OnInspectorGUI(terrain, editContext);

            m_ShowControls = TerrainToolGUIHelper.DrawHeaderFoldout(Erosion.Styles.m_ThermalErosionControls, m_ShowControls);
            if (m_ShowControls)
            {
                EditorGUILayout.BeginVertical("GroupBox");

                /*m_AffectHeight = EditorGUILayout.Toggle(Erosion.Styles.m_AffectHeight, m_AffectHeight);
                 *
                 * if (m_AffectHeight) {
                 *  m_AddHeightAmt = EditorGUILayout.IntSlider(Erosion.Styles.m_AddHeight, m_AddHeightAmt, 0, 100);
                 * }*/

                string[] matNames =
                {
                    "Custom",
                    "Dry Ash",       // 40
                    "Chalk",         // 45
                    "Dry Clay",      // 25 - 40
                    "Wet Clay",      // 15
                    "Soil",          // 30-45
                    "Granite Scree", // 35 - 40
                    "Gravel",        //45 - 45
                    "Dry Sand",
                    "Wet Sand",
                    "Quick Sand",
                    "Snow"
                };

                float[,] tauValues = new float[, ] {
                    { -1.0f, -1.0f },  //custom
                    { 38.0f, 42.0f },  //dry ash
                    { 45.0f, 45.0f },  //chalk
                    { 25.0f, 40.0f },  //dry clay (25 - 40)
                    { 15.0f, 15.0f },  //wet clay
                    { 30.0f, 45.0f },  //soil (30-45)
                    { 35.0f, 40.0f },  //crushed granite (35 - 40)
                    { 45.0f, 45.0f },  //gravel
                    { 32.0f, 36.0f },  //dry sand
                    { 45.0f, 45.0f },  //wet sand
                    { 15.0f, 30.0f },  //quicksand (15-30)
                    { 38.0f, 38.0f }   //snow
                };

                EditorGUI.BeginChangeCheck();
                m_Eroder.m_MatPreset = EditorGUILayout.Popup(Erosion.Styles.m_MatPreset, m_Eroder.m_MatPreset, matNames);
                if (EditorGUI.EndChangeCheck() && m_Eroder.m_MatPreset != 0)
                {
                    m_Eroder.m_AngleOfRepose.x = tauValues[m_Eroder.m_MatPreset, 0];
                    m_Eroder.m_AngleOfRepose.y = tauValues[m_Eroder.m_MatPreset, 1];
                }

                EditorGUI.indentLevel++;
                m_ShowAdvancedUI = EditorGUILayout.Foldout(m_ShowAdvancedUI, "Advanced");
                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);
                    //m_ReposeNoiseScale = EditorGUILayout.Slider("Material Variation Scale", m_ReposeNoiseScale, 0.0001f, 1.0f);
                    //m_ReposeNoiseAmount = EditorGUILayout.Slider("Material Variation Amount", m_ReposeNoiseAmount, 0.0f, 1.0f);
                }

                /*
                 * m_ShowMaterialUI = EditorGUILayout.Foldout(m_ShowMaterialUI, "Material");
                 * if (m_ShowMaterialUI) {
                 *  m_AffectMaterial = EditorGUILayout.Toggle(Erosion.Styles.m_AffectMaterial, m_AffectMaterial);
                 *  if (m_AffectMaterial) {
                 *      m_MaterialPaintStrength = EditorGUILayout.IntSlider(Erosion.Styles.m_MaterialPaintStrength, m_MaterialPaintStrength, -100, 100);
                 *
                 *      EditorGUI.BeginChangeCheck();
                 *
                 *      int layerIndex = TerrainPaintUtility.FindTerrainLayerIndex(terrain, m_SelectedTerrainLayer);
                 *      layerIndex = TerrainLayerUtility.ShowTerrainLayersSelectionHelper(terrain, layerIndex);
                 *      if (EditorGUI.EndChangeCheck()) {
                 *          if (layerIndex != -1)
                 *              m_SelectedTerrainLayer = terrain.terrainData.terrainLayers[layerIndex];
                 *
                 *          Save(true);
                 *      }
                 *  }
                 * }
                 */
                EditorGUILayout.EndVertical();
            }

            if (EditorGUI.EndChangeCheck())
            {
                Save(true);
            }
        }
        public override void DoGUI(Rect rect)
        {
            if (m_noiseSettings == null)
            {
                m_noiseSettings = ScriptableObject.CreateInstance <NoiseSettings>();
            }

            GUIContent localLabel     = NoiseFilter.localLabel;
            GUIContent worldLabel     = NoiseFilter.worldLabel;
            GUIContent heightmapLabel = NoiseFilter.heightmapLabel;
            GUIContent editLabel      = NoiseFilter.editLabel;

            float editWith = GUI.skin.label.CalcSize(editLabel).x + 20f;
            Rect  editRect = new Rect(rect.xMax - editWith, rect.y, editWith, rect.height);

            Rect labelRect = rect;

            labelRect.width = GUI.skin.label.CalcSize(coordinateLabel).x;

            Rect worldRect = labelRect;

            worldRect.x     = labelRect.xMax;
            worldRect.width = GUI.skin.button.CalcSize(worldLabel).x + 10f;

            Rect localRect = worldRect;

            localRect.x     = worldRect.xMax;
            localRect.width = GUI.skin.button.CalcSize(localLabel).x + 10f;

            Rect heightmapRect = localRect;

            heightmapRect.x     = localRect.xMax + 10f;
            heightmapRect.width = GUI.skin.button.CalcSize(heightmapLabel).x + 10f;

            if (editRect.xMin < heightmapRect.xMax + 10f)
            {
                worldRect.x     -= labelRect.width;
                localRect.x     -= labelRect.width;
                heightmapRect.x -= labelRect.width;
                labelRect.width  = 0;
            }

            editRect.x = Mathf.Max(editRect.x, heightmapRect.xMax + 4f);

            if (editRect.xMax > rect.xMax)
            {
                worldLabel          = NoiseFilter.worldShortLabel;
                localLabel          = NoiseFilter.localShortLabel;
                heightmapLabel      = NoiseFilter.heightmapShortLabel;
                worldRect.width     = GUI.skin.label.CalcSize(worldLabel).x + 10f;
                localRect.width     = GUI.skin.label.CalcSize(localLabel).x + 10f;
                heightmapRect.width = GUI.skin.label.CalcSize(heightmapLabel).x + 10f;
                localRect.x         = worldRect.xMax;
                heightmapRect.x     = localRect.xMax + 10f;

                editRect.x = rect.xMax - editWith;
            }

            editRect.x = Mathf.Max(heightmapRect.xMax + 4f, editRect.x);

            if (editRect.xMax > rect.xMax)
            {
                editLabel      = editShortLabel;
                editRect.width = GUI.skin.label.CalcSize(editLabel).x + 10f;
            }

            GUI.Label(labelRect, coordinateLabel);

            if (TerrainToolGUIHelper.ToggleButton(worldRect, worldLabel, !m_isLocalSpace))
            {
                m_isLocalSpace = false;
            }

            if (TerrainToolGUIHelper.ToggleButton(localRect, localLabel, m_isLocalSpace))
            {
                m_isLocalSpace = true;
            }

            m_useHeightmap = TerrainToolGUIHelper.ToggleButton(heightmapRect, heightmapLabel, m_useHeightmap);

            m_noiseSettings.useTextureForPositions = m_useHeightmap;

            if (GUI.Button(editRect, editLabel))
            {
                NoiseWindow wnd = NoiseWindow.Create(m_noiseSettings, m_noiseSource);
                wnd.noiseEditorView.onSettingsChanged += (noise) =>
                {
                    m_noiseSettings.Copy(noise);
                };
                wnd.noiseEditorView.onSourceAssetChanged += (noise) =>
                {
                    m_noiseSource = noise;
                };
                wnd.onDisableCallback += () =>
                {
                    m_window = null;
                };

                m_window = wnd;
            }
        }
        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            base.OnInspectorGUI(terrain, editContext);

            m_BrushScatter = TerrainToolGUIHelper.PercentSlider(styles.brushScatter, m_BrushScatter, 0.0f, 1.0f);
        }
Exemple #30
0
        //===================================================================================================
        //
        //      NOISE TOOL GUI
        //
        //===================================================================================================

        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            Init();

            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 (TerrainToolGUIHelper.ToggleButton(Styles.worldSpace, m_toolSettings.coordSpace == CoordinateSpace.World))
                        {
                            m_toolSettings.coordSpace = CoordinateSpace.World;
                        }

                        if (TerrainToolGUIHelper.ToggleButton(Styles.brushSpace, m_toolSettings.coordSpace == CoordinateSpace.Brush))
                        {
                            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);
            }
        }