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); }
public PathPaintTool() { #region Modules // register available modules this.modules = new List <ModuleEditor>(); this.modules.Add(paintModule); this.modules.Add(bridgeModule); this.modules.Add(smoothModule); this.modules.Add(heightModule); this.modules.Add(ridgeErodeModule); this.modules.Add(smudgeModule); this.modules.Add(underlayModule); // sort order in OnSceneGui this.onSceneGuiOrderList = new List <ModuleEditor>(); this.onSceneGuiOrderList.AddRange(this.modules); this.onSceneGuiOrderList = this.modules.OrderBy(x => x.SceneGuiOrder).ToList(); // sort order in paintSegment execution this.paintSegmentOrderList = new List <ModuleEditor>(); this.paintSegmentOrderList.AddRange(this.modules); this.paintSegmentOrderList = this.modules.OrderBy(x => x.PaintSegmentOrder).ToList(); #endregion Modules #region Paint Mode // register available paint modes paintModes = new List <IPaintMode>(); this.paintModes.Add(new PaintBrushPaintMode()); this.paintModes.Add(new StrokePaintMode()); this.paintModes.Add(new WaypointPaintMode()); this.paintModes.Add(new SplinePaintMode()); // set initial paint mode this.paintModeIndex = 0; // select the first item this.paintMode = this.paintModes[this.paintModeIndex]; #endregion Paint Mode // register asset integrations assetIntegrations = new List <AssetIntegration>(); if (vegetationStudioProIntegration.Enabled) { assetIntegrations.Add(vegetationStudioProIntegration); } if (vegetationStudioIntegration.Enabled) { assetIntegrations.Add(vegetationStudioIntegration); } #region Delayed Action this.delayedActionHandler = new DelayedActionHandler(); this.delayedActionHandler.AddDelayedAction(new DelayedAction(this)); #endregion Delayed Action #region PathRecorder pathRecorder = new PathRecorder(); #endregion PathRecorder }
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); }