Пример #1
0
        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            EditorGUI.BeginChangeCheck();
            {
                #region General Notification

                EditorGUILayout.HelpBox("Please note that Undo isn't implemented yet. Better backup your terrain before you perform any modifications.", MessageType.Info);

                #endregion General Notification


                #region Module Editor

                GUILayout.BeginVertical("box");
                {
                    GUILayout.Label(PathPaintStyles.activeTerrainToolsContent, EditorStyles.boldLabel);

                    EditorGUILayout.BeginHorizontal();

                    foreach (ModuleEditor module in modules)
                    {
                        // toggle active state
                        if (GUILayout.Button(module.GetName(), PathPaintStyles.GetButtonToggleStyle(module.Active)))
                        {
                            module.Active = !module.Active;
                        }
                    }


                    EditorGUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();

                #endregion Module Editor


                #region Paint Mode

                GUILayout.BeginVertical("box");
                {
                    List <GUIContent> paintModeContents = new List <GUIContent>();
                    foreach (IPaintMode editor in paintModes)
                    {
                        paintModeContents.Add(new GUIContent(editor.GetName(), editor.GetDescription()));
                    }

                    EditorGUILayout.LabelField(PathPaintStyles.paintModesContent, EditorStyles.boldLabel);

                    EditorGUILayout.BeginHorizontal();

                    paintModeIndex = GUILayout.Toolbar(paintModeIndex, paintModeContents.ToArray());
                    paintMode      = paintModes[paintModeIndex];

                    EditorGUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical("box");
                {
                    paintMode.OnInspectorGUI(terrain, editContext, brushSettings);
                }
                GUILayout.EndVertical();

                #endregion Paint Mode


                #region Module Editor Settings

                foreach (ModuleEditor module in modules)
                {
                    if (!module.Active)
                    {
                        continue;
                    }

                    GUILayout.BeginVertical("box");
                    {
                        if (module.GetDescription().Length > 0)
                        {
                            EditorGUILayout.HelpBox(module.GetDescription(), MessageType.Info);
                        }

                        module.OnInspectorGUI(terrain, editContext, brushSettings);
                    }
                    GUILayout.EndVertical();
                }

                #endregion Module Editor Settings


                #region Brush

                GUILayout.BeginVertical("box");
                {
                    // editContext.ShowBrushesGUI(0);

                    #region BrushSettings

                    // show the brush templates
                    editContext.ShowBrushesGUI(0, BrushGUIEditFlags.Select);

                    // info
                    EditorGUILayout.HelpBox(PathPaintStyles.brushSettingsHelp.text, MessageType.None);

                    if (showBrushSize)
                    {
                        float safetyFactorHack = 0.9375f;
                        brushSettings.brushSize = EditorGUILayout.Slider(PathPaintStyles.brushSizeStyle, brushSettings.brushSize, 0.1f, Mathf.Round(Mathf.Min(terrain.terrainData.size.x, terrain.terrainData.size.z) * safetyFactorHack));
                    }

                    if (showBrushStrength)
                    {
                        brushSettings.brushStrength = PercentSlider(PathPaintStyles.brushOpacityStyle, brushSettings.brushStrength, kMinBrushStrength, 1); // former string formatting: "0.0%"
                    }

                    if (showBrushRotation)
                    {
                        brushSettings.brushRotationDegrees = EditorGUILayout.Slider(PathPaintStyles.brushRotationStyle, brushSettings.brushRotationDegrees, 0, 359);
                        brushSettings.brushRotationDegrees = brushSettings.brushRotationDegrees % 360;
                    }

                    #endregion BrushSettings
                }
                GUILayout.EndVertical();

                #endregion Brush

                #region Integrations
                foreach (AssetIntegration asset in assetIntegrations)
                {
                    GUILayout.BeginVertical("box");
                    {
                        asset.OnInspectorGUI();
                    }
                    GUILayout.EndVertical();
                }
                #endregion Integrations

                #region Debug

                GUILayout.BeginVertical("box");
                {
                    EditorGUILayout.LabelField(PathPaintStyles.debugContent, EditorStyles.boldLabel);

                    pathRecorderEnabled = EditorGUILayout.Toggle("Show Path", pathRecorderEnabled);
                }
                GUILayout.EndVertical();
                #endregion Debug
            }
            if (EditorGUI.EndChangeCheck())
            {
                Save(true);

                // update scene view, otherwise eg changing the "show path" option wouldn't be visualized immediately
                SceneView.RepaintAll();
            }

            base.OnInspectorGUI(terrain, editContext);
        }
Пример #2
0
        public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
        {
            EditorGUI.BeginChangeCheck();
            {
                #region General Notification

                EditorGUILayout.HelpBox("Please note that Undo isn't implemented yet. Better backup your terrain before you perform any modifications.", MessageType.Info);

                #endregion General Notification


                #region Module Editor

                GUILayout.BeginVertical("box");
                {
                    GUILayout.Label(PathPaintStyles.activeTerrainToolsContent, EditorStyles.boldLabel);

                    EditorGUILayout.BeginHorizontal();

                    foreach (ModuleEditor module in modules)
                    {
                        // toggle active state
                        if (GUILayout.Button(module.GetName(), PathPaintStyles.GetButtonToggleStyle(module.Active)))
                        {
                            module.Active = !module.Active;
                        }
                    }


                    EditorGUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();

                #endregion Module Editor


                #region Paint Mode

                GUILayout.BeginVertical("box");
                {
                    List <GUIContent> paintModeContents = new List <GUIContent>();
                    foreach (IPaintMode editor in paintModes)
                    {
                        paintModeContents.Add(new GUIContent(editor.GetName(), editor.GetDescription()));
                    }

                    EditorGUILayout.LabelField(PathPaintStyles.paintModesContent, EditorStyles.boldLabel);

                    EditorGUILayout.BeginHorizontal();

                    paintModeIndex = GUILayout.Toolbar(paintModeIndex, paintModeContents.ToArray());
                    paintMode      = paintModes[paintModeIndex];

                    EditorGUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical("box");
                {
                    paintMode.OnInspectorGUI(terrain, editContext);
                }
                GUILayout.EndVertical();

                #endregion Paint Mode


                #region Module Editor Settings

                foreach (ModuleEditor module in modules)
                {
                    if (!module.Active)
                    {
                        continue;
                    }

                    GUILayout.BeginVertical("box");
                    {
                        if (module.GetDescription().Length > 0)
                        {
                            EditorGUILayout.HelpBox(module.GetDescription(), MessageType.Info);
                        }

                        module.OnInspectorGUI(terrain, editContext);
                    }
                    GUILayout.EndVertical();
                }

                #endregion Module Editor Settings


                #region Brush

                GUILayout.BeginVertical("box");
                {
                    editContext.ShowBrushesGUI(0);
                }
                GUILayout.EndVertical();

                #endregion Brush

                #region Integrations
                foreach (AssetIntegration asset in assetIntegrations)
                {
                    GUILayout.BeginVertical("box");
                    {
                        asset.OnInspectorGUI();
                    }
                    GUILayout.EndVertical();
                }
                #endregion Integrations

                #region Debug

                GUILayout.BeginVertical("box");
                {
                    EditorGUILayout.LabelField(PathPaintStyles.debugContent, EditorStyles.boldLabel);

                    pathRecorderEnabled = EditorGUILayout.Toggle("Show Path", pathRecorderEnabled);
                }
                GUILayout.EndVertical();
                #endregion Debug
            }
            if (EditorGUI.EndChangeCheck())
            {
                Save(true);

                // update scene view, otherwise eg changing the "show path" option wouldn't be visualized immediately
                SceneView.RepaintAll();
            }

            base.OnInspectorGUI(terrain, editContext);
        }