private static bool IsPaintTab(TP tpc) { if (!tpc.Alpha.Enabled) { return(false); } switch (tpc.EditingTool) { case EditingTool.Height: break; case EditingTool.Texture: switch (tpc.SplatTool) { case SplatTool.OneTexture: case SplatTool.HeightBased: case SplatTool.AngleBased: case SplatTool.Sharpen: case SplatTool.Blur: return(true); } break; case EditingTool.Foliage: return(true); case EditingTool.Object: break; } return(false); }
protected void DrawSlopeEditor(TP tp, Action additional) { // Draw label EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); tp.Ramp.Active = GUILayout.Toggle(tp.Ramp.Active, new GUIContent()); DrawTitleLabel("Ramp"); EditorGUILayout.EndHorizontal(); Seperator(1); if (tp.Ramp.Active || component.SplatTool == SplatTool.AngleBased) { // Get current slope values float min = component.Ramp.Min; float max = component.Ramp.Max; GUILayout.BeginHorizontal(); // Draw label GUILayout.Label("Ramp \t"); Seperator(3); min = EditorGUILayout.FloatField(min, new GUILayoutOption[0]); GUILayout.Label(new GUIContent(" / "), new GUILayoutOption[0]); max = EditorGUILayout.FloatField(max, new GUILayoutOption[0]); Seperator(8); GUILayout.EndHorizontal(); // Draw start- end-height slider EditorGUILayout.MinMaxSlider(ref min, ref max, 0.0f, 90.0f); // Fix values if needed if (min <= 0.01f) { if (min + 0.01f > max) { max = min + 0.01f; } } else if (min + 0.01f > max) { min = max - 0.01f; } component.Ramp.Set(Mathf.Clamp(min, 0.01f, 90.0f), Mathf.Clamp(max, 0.00f, 89.99f)); //DrawSlopeCurve(); if (additional != null) { additional(); } } EditorGUILayout.EndVertical(); }
internal override void OnInspectorGUI(TP c) { base.OnInspectorGUI(c); component.Foliages.Erase = DrawSwitch(component.Foliages.Erase , "paint", "erase"); DrawFoliageSelectorEditor(); DrawAlphaSelector(component, TP.Colors.SelectedPaintTextureColor); DrawSlopeEditor(component, null); DrawNoiseEditor(component, component.TerrainData.detailResolution); if (!component.HidePaintAll) { DrawPaintAllButton(); } }
internal override void OnInspectorGUI(TP c) { base.OnInspectorGUI(c); component.Foliages.Erase = DrawSwitch(component.Foliages.Erase, "paint", "erase"); DrawFoliageSelectorEditor(); DrawAlphaSelector(component, TP.Colors.SelectedPaintTextureColor); DrawSlopeEditor(component, null); DrawNoiseEditor(component, component.TerrainData.detailResolution); if (!component.HidePaintAll) { DrawPaintAllButton(); } }
internal override void OnSceneGUI(TP component) { base.OnSceneGUI(component); }
internal override void OnInspectorGUI(TP component) { base.OnInspectorGUI(component); // Set brush projector color GUILayout.Label(new GUIContent("Brush"), EditorStyles.boldLabel); tp_Projector.BrushInactiveColor = EditorGUILayout.ColorField(new GUIContent("Inactive Color"), tp_Projector.BrushInactiveColor); tp_Projector.BrushActiveColor = EditorGUILayout.ColorField(new GUIContent("Active Color"), tp_Projector.BrushActiveColor); component.BrushRotationSensitivity = EditorGUILayout.FloatField(new GUIContent("Rotating sensitivity"), component.BrushRotationSensitivity); EditorGUILayout.BeginHorizontal(); Seperator(1); if (GUILayout.Button("Load Deafault")) { LoadDefault(); } EditorGUILayout.EndHorizontal(); Seperator(3); // Undo GUILayout.Label(new GUIContent("History"), EditorStyles.boldLabel); component.History.Capacity = EditorGUILayout.IntField(new GUIContent("Undo Capacity", "How may time undo can be performed"), component.History.Capacity); Seperator(3); // Save load Settings EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Settings"), EditorStyles.boldLabel); FlexibleSpace(5); if (GUILayout.Button("Save..")) { SaveSettings(); } if (GUILayout.Button("Load..")) { LoadSettings(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("You can save and load your settings \ni.e. Height settings, projector colors"), EditorStyles.label); EditorGUILayout.EndVertical(); Seperator(3); // Save load terrain splat EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Splatmaps"), EditorStyles.boldLabel); FlexibleSpace(5); if (GUILayout.Button("Save..")) { SaveSplatMap(); } if (GUILayout.Button("Load..")) { LoadSplatMap(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("NOTE: The process could take \"a few\" seconds; \ndepending on your system, \nsplatmap size and amount of splatmaps.\n\nNOTE: Make sure the loaded splatmap-resolution \nmatches the terrain splatmap-resolution"), EditorStyles.miniLabel); EditorGUILayout.EndVertical(); Seperator(3); GUILayout.Label(new GUIContent("Foliage"), EditorStyles.boldLabel); component.MaxFoliageStrength = EditorGUILayout.IntField(new GUIContent("Max Foliage Strength"), component.MaxFoliageStrength, new GUILayoutOption[0]); component.MaxFoliageStrength = Mathf.Max(1, component.MaxFoliageStrength); Seperator(3); // Hide/Show Paint all EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Paint all Button: "), EditorStyles.boldLabel); component.HidePaintAll = DrawSwitch(component.HidePaintAll, "Show", "Hide"); EditorGUILayout.EndHorizontal(); Seperator(3); // Lock/Unlock splatmap EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Lock Splatmap: "), EditorStyles.boldLabel); component.SplatmapLock = DrawSwitch(component.SplatmapLock, "Unlock", "Lock"); EditorGUILayout.EndHorizontal(); Seperator(3); // Tooltip level EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Tooltip Level: "), EditorStyles.boldLabel); component.TooltipLevel = EditorGUILayout.IntSlider(component.TooltipLevel, 0, TP.MAX_TOOLTIP_LEVEL); EditorGUILayout.EndHorizontal(); DrawTooltip(0, "Tooltip level", new string[] { "No tooltips will be shown at all", "Some tooltips will be shown", "All tooltips will be shown" }); }
internal override void OnSceneGUI(TP c) { base.OnSceneGUI(c); }
internal virtual void OnSceneGUI(TP c) { m_component = c; }
internal virtual void OnInspectorGUI(TP c) { m_component = c; }
protected void DrawSlopeEditor(TP tp, Action additional) { // Draw label EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); tp.Ramp.Active = GUILayout.Toggle(tp.Ramp.Active, new GUIContent()); DrawTitleLabel("Ramp"); EditorGUILayout.EndHorizontal(); Seperator(1); if (tp.Ramp.Active || component.SplatTool == SplatTool.AngleBased) { // Get current slope values float min = component.Ramp.Min; float max = component.Ramp.Max; GUILayout.BeginHorizontal(); // Draw label GUILayout.Label("Ramp \t"); Seperator(3); min = EditorGUILayout.FloatField(min, new GUILayoutOption[0]); GUILayout.Label(new GUIContent(" / "), new GUILayoutOption[0]); max = EditorGUILayout.FloatField(max, new GUILayoutOption[0]); Seperator(8); GUILayout.EndHorizontal(); // Draw start- end-height slider EditorGUILayout.MinMaxSlider(ref min, ref max, 0.0f, 90.0f); // Fix values if needed if (min <= 0.01f) { if (min + 0.01f > max) { max = min + 0.01f; } } else if (min + 0.01f > max) { min = max - 0.01f; } component.Ramp.Set(Mathf.Clamp(min, 0.01f, 90.0f), Mathf.Clamp(max, 0.00f, 89.99f)); //DrawSlopeCurve(); if (additional != null) { additional(); } } EditorGUILayout.EndVertical(); }
internal override void OnSceneGUI(TP component) { base.OnSceneGUI(component); }
public void DrawAlphaSelector(TP tp, Color color) { // Draw label Rect position = EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); tp.Alpha.Enabled = GUILayout.Toggle(tp.Alpha.Enabled, new GUIContent()); DrawTitleLabel("Alpha"); EditorGUILayout.EndHorizontal(); Seperator(1); // Settings Color tempColor = GUI.backgroundColor; if (tp.Alpha.Enabled) { // Size slider tp.BrushSize = EditorGUILayout.FloatField(new GUIContent("Size"), tp.BrushSize, new GUILayoutOption[0]); tp.BrushRotation = EditorGUILayout.FloatField(new GUIContent("Angle"), tp.BrushRotation); DrawTooltip(1, "", new string[] { "Press ctrl and drag mouse to rotate the brush", "Press ctrl and drag mouse to rotate the brush" }); position = EditorGUILayout.BeginVertical(); EditorGUILayout.EndVertical(); const int imgSize = 50; const int spacing = 4; float totalSpacing = (float)spacing; position.width = Screen.width - (20.0f + spacing * 2.0f); // Set potition Rect current = position; current.width = current.height = imgSize; current.x += spacing; current.y += spacing; // Get amount of columns int columnCount = (int)((position.width - (2 * spacing)) / (spacing + imgSize)); for (int i = 0; i < tp.Alpha.alphaBrushes.Count; i++) { if (i > 0 && i % columnCount == 0) { // New line totalSpacing += imgSize + spacing; current.x = position.x + spacing; current.y = position.y + totalSpacing; } else if (i != 0) { current.x += imgSize + spacing; } // Set colour, set selected alpha texture if (i == (int)tp.Alpha) { GUI.backgroundColor = color; } else { GUI.backgroundColor = TP.Colors.UnSelectedColor; } if (GUI.Button(current, tp.Alpha.alphaBrushes[i])) { tp.Alpha.selectedAlphaBrush = i; } } GUI.backgroundColor = tempColor; totalSpacing += imgSize + spacing; GUILayout.Space(totalSpacing); // Update button EditorGUILayout.BeginHorizontal(); FlexibleSpace(5); if (GUILayout.Button(new GUIContent("update.."))) { tp.Alpha.Update(); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); // Reset color GUI.color = tempColor; }
internal override void OnSceneGUI(TP c) { base.OnSceneGUI(c); }
/// <summary> /// Get input /// </summary> /// <param name="method">Delegate method</param> /// <param name="position">Mouse world position</param> /// <param name="active">Is painting</param> /// <param name="saveMsg">Undo message</param> internal static void Update(TP component, tp_ComponentBaseEditor target, ref Vector3 position, ref bool active, string saveMsg = default(string)) { // Get current event Event current = Event.current; // checkkeys int controlID = GUIUtility.GetControlID(TP.HashCode, FocusType.Passive); int hotControl = GUIUtility.hotControl; EventType filteredControlID = current.GetTypeForControl(controlID); switch (filteredControlID) { // (If mouse down or mouse drag) case EventType.MouseDown: case EventType.MouseDrag: // Check if current control is Terrain Painter control if (hotControl != controlID && (hotControl != 0) || TP.Instance.SplatmapLock || RotateButtonPressed) { return; } if (current.button != 0 || HandleUtility.nearestControl != controlID || (TP.Instance.EditingTool == EditingTool.Texture && TP.Instance.SplatTool == SplatTool.None)) { return; } if (current.type == EventType.MouseDown) { GUIUtility.hotControl = controlID; } if (!GetPosition(out position)) { break; } if (current.type == EventType.MouseDown) { // Save current splatmap TP.Instance.History.CreateRestorePoint(target.UndoType, saveMsg); if (TP.Instance.Noise.GenerateOnClick) { TP.Instance.Noise.Generate(new Point(component.TerrainData.alphamapWidth, component.TerrainData.alphamapHeight)); } } // Run method, and Painting is in use if (target != null) { target.Paint(false); } active = true; current.Use(); break; // Update projector position case EventType.MouseMove: if (GetPosition(out position)) { HandleUtility.Repaint(); } break; // Disable painting, and current control is not Terrain Painter any more case EventType.MouseUp: active = false; if (hotControl != controlID || TP.Instance.SplatmapLock) { return; } GUIUtility.hotControl = hotControl = 0; if (TP.Instance.EditingTool == EditingTool.Texture && TP.Instance.SplatTool == SplatTool.None) { return; } current.Use(); break; // Disable the selection tool case EventType.Layout: if (RotateButtonPressed) { HandleUtility.AddDefaultControl(controlID); HandleUtility.Repaint(); current.Use(); break; } if ((TP.Instance.EditingTool == EditingTool.Texture && TP.Instance.SplatTool == SplatTool.None) || TP.Instance.SplatmapLock) { return; } HandleUtility.AddDefaultControl(controlID); break; } }
/// <summary> /// Update Projector /// </summary> /// <param name="isPainting"></param> public void Update(bool isPainting) { TP tpc = TP.Instance; if (tpc == null || tpc.SplatmapLock || !IsPaintTab(tpc)) { DisableProjector(); return; } /* * * if key -> prev mouse pos - cur mouse pos * val * sensitivity * brush rot + val * */ Vector2 mousePosition = Event.current.mousePosition; if (tp_Input.RotateButtonPressed) { EditorGUIUtility.SetWantsMouseJumping((int)EventModifiers.Alt); if (m_previousMousePosition.HasValue) { float change = m_previousMousePosition.Value.x - mousePosition.x; tpc.BrushRotation += change * tpc.BrushRotationSensitivity; } else { m_startRotationAngle = mousePosition; } m_previousMousePosition = mousePosition; mousePosition = m_startRotationAngle; } else { if (m_previousMousePosition.HasValue) { Event.current.mousePosition = m_startRotationAngle; } m_previousMousePosition = null; } Ray ray = HandleUtility.GUIPointToWorldRay(mousePosition + TP.Settings.BRUSH_OFFSET); RaycastHit hit; if (tpc.Terrain.GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity)) { Create(); EnableProjector(); UpdateColorLerp(isPainting); UpdateProjector(hit.point, tpc.BrushSize); m_brushProjectorTransform.position += Vector3.up * tpc.Transform.position.y; m_brushProjectorTransform.eulerAngles = new Vector3(90.0f, tpc.BrushRotation, 0.0f); return; } DisableProjector(); }
internal override void OnInspectorGUI(TP c) { base.OnInspectorGUI(c); // Toolbar GUILayout.BeginHorizontal(); FlexibleSpace(5); component.SplatTool = (SplatTool)GUILayout.Toolbar((int)component.SplatTool, m_toolbarItems, ToolbarOptions(m_toolbarItems.Length)); FlexibleSpace(5); GUILayout.EndHorizontal(); // switch (c.SplatTool) { case SplatTool.OneTexture: DrawTooltip(2, "", new string[] { "Paint with one texture" }); EditorGUILayout.BeginVertical(EditorStyles.helpBox); DrawBrushSettings(); DrawSelectorEditor(m_textureContainer, TextureSelectType.Default); break; case SplatTool.HeightBased: DrawTooltip(2, "", new string[] { "Paint textures based on height" }); EditorGUILayout.BeginVertical(EditorStyles.helpBox); DrawBrushSettings(); DrawHeightEditor(); break; case SplatTool.AngleBased: DrawTooltip(2, "", new string[] { "Paint only the terrain slopes" }); EditorGUILayout.BeginVertical(EditorStyles.helpBox); DrawBrushSettings(); break; case SplatTool.Sharpen: DrawTooltip(2, "", new string[] { "Sharpen texture transitions" }); EditorGUILayout.BeginVertical(EditorStyles.helpBox); DrawBrushSettings(); component.SharpenStrength = EditorGUILayout.Slider(new GUIContent("Sharpen Strength", "Strength of sharpening"), component.SharpenStrength, 1.0f, 10.0f); component.Textures.IsMultiSelect = EditorGUILayout.Toggle(new GUIContent("Use selected textures", "Aplly sharpen to selected textures (disabling this will apply to all textures)"), component.Textures.IsMultiSelect); if (component.Textures.IsMultiSelect) { DrawSelectorEditor(m_cliffContainer, TextureSelectType.Multi); } EditorGUILayout.EndVertical(); DrawAlphaSelector(component, TP.Colors.SelectedPaintTextureColor); PaintAllEditor(); return; case SplatTool.Blur: DrawTooltip(2, "", new string[] { "Smooth texture transitions" }); EditorGUILayout.BeginVertical(EditorStyles.helpBox); DrawBrushSettings(); component.SmoothStrength = EditorGUILayout.IntSlider(new GUIContent("Blur Strength", "Blurring Radius/Strength"), component.SmoothStrength, 1, 8); component.Textures.IsMultiSelect = EditorGUILayout.Toggle(new GUIContent("Use selected textures", "Aplly smoothing to selected textures (disabling this will apply to all textures)"), component.Textures.IsMultiSelect); if (component.Textures.IsMultiSelect) { DrawSelectorEditor(m_cliffContainer, TextureSelectType.Multi); } EditorGUILayout.EndVertical(); DrawAlphaSelector(component, TP.Colors.SelectedPaintTextureColor); PaintAllEditor(); return; default: DrawNone(); return; } EditorGUILayout.EndVertical(); DrawAlphaSelector(component, TP.Colors.SelectedPaintTextureColor); DrawNoiseEditor(component, component.TerrainData.alphamapResolution); DrawSlopeEditor(component, DrawCliffSelectorEditor); PaintAllEditor(); }
/// <summary> /// Get input /// </summary> /// <param name="method">Delegate method</param> /// <param name="position">Mouse world position</param> /// <param name="active">Is painting</param> /// <param name="saveMsg">Undo message</param> internal static void Update(TP component, tp_ComponentBaseEditor target, ref Vector3 position, ref bool active, string saveMsg = default(string)) { // Get current event Event current = Event.current; // checkkeys int controlID = GUIUtility.GetControlID(TP.HashCode, FocusType.Passive); int hotControl = GUIUtility.hotControl; EventType filteredControlID = current.GetTypeForControl(controlID); switch (filteredControlID) { // (If mouse down or mouse drag) case EventType.MouseDown: case EventType.MouseDrag: // Check if current control is Terrain Painter control if (hotControl != controlID && (hotControl != 0) || TP.Instance.SplatmapLock || RotateButtonPressed) { return; } if (current.button != 0 || HandleUtility.nearestControl != controlID || (TP.Instance.EditingTool == EditingTool.Texture && TP.Instance.SplatTool == SplatTool.None)) { return; } if (current.type == EventType.MouseDown) { GUIUtility.hotControl = controlID; } if (!GetPosition(out position)) { break; } if (current.type == EventType.MouseDown) { // Save current splatmap TP.Instance.History.CreateRestorePoint(target.UndoType, saveMsg); if (TP.Instance.Noise.GenerateOnClick) { TP.Instance.Noise.Generate(new Point(component.TerrainData.alphamapWidth, component.TerrainData.alphamapHeight)); } } // Run method, and Painting is in use if (target != null) { target.Paint(false); } active = true; current.Use(); break; // Update projector position case EventType.MouseMove: if (GetPosition(out position)) { HandleUtility.Repaint(); } break; // Disable painting, and current control is not Terrain Painter any more case EventType.MouseUp: active = false; if (hotControl != controlID || TP.Instance.SplatmapLock) { return; } GUIUtility.hotControl = hotControl = 0; if (TP.Instance.EditingTool == EditingTool.Texture && TP.Instance.SplatTool == SplatTool.None) { return; } current.Use(); break; // Disable the selection tool case EventType.Layout: if (RotateButtonPressed) { HandleUtility.AddDefaultControl(controlID); HandleUtility.Repaint(); current.Use(); break; } if ((TP.Instance.EditingTool == EditingTool.Texture && TP.Instance.SplatTool == SplatTool.None) || TP.Instance.SplatmapLock) { return; } HandleUtility.AddDefaultControl(controlID); break; } }
internal virtual void OnInspectorGUI(TP c) { m_component = c; }
public static void DrawNoiseEditor(TP tp, int resolution) { // Draw label EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); tp.Noise.Enabled = GUILayout.Toggle(tp.Noise.Enabled, new GUIContent()); DrawTitleLabel("Noise"); EditorGUILayout.EndHorizontal(); Seperator(1); //tp.Noise.Enabled = EditorGUILayout.ToggleLeft(new GUIContent("Noise"), tp.Noise.Enabled, EditorStyles.boldLabel, new GUILayoutOption[0]); // If noise is enabled if (tp.Noise.Enabled) { // Texture preview Settings const int previewSize = 100; EditorGUILayout.BeginHorizontal(); Rect current = EditorGUILayout.BeginVertical(); // Get texture Texture2D tex = new Texture2D(previewSize, previewSize); tex.hideFlags = HideFlags.HideAndDontSave; // Draw preview texture if (tp.Noise.Texture != null) { tex = tp.Noise.Texture; } current.height = current.width = previewSize; GUI.Label(current, new GUIContent(tex, tex.name)); // Offset current.y += previewSize + 2.0f; current.height = 16.0f; // Draw generate button if (GUI.Button(current, new GUIContent("Generate"))) { //tp.Noise.Generate(new Point(tp.TerrainData.alphamapWidth, tp.TerrainData.alphamapHeight)); tp.Noise.Generate(new Point(resolution, resolution)); } EditorGUILayout.EndVertical(); GUILayout.Space(previewSize + 2.0f); // Settings EditorGUILayout.BeginVertical(); // Draw generate on click checkbox tp.Noise.GenerateOnClick = EditorGUILayout.Toggle(new GUIContent("Generate on click", "Generate new splatmap on mousebutton down"), tp.Noise.GenerateOnClick, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("Scale", "Noise scale"), new GUILayoutOption[0]); tp.Noise.Scale = EditorGUILayout.FloatField(tp.Noise.Scale, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("Octaves", "Amount of iterations applied"), new GUILayoutOption[0]); tp.Noise.Octaves = EditorGUILayout.IntSlider(tp.Noise.Octaves, 1, 10, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("Gain", "Gain of each iteration"), new GUILayoutOption[0]); tp.Noise.Gain = EditorGUILayout.Slider(tp.Noise.Gain, 0.1f, 0.9f, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("Lacunarity", ""), new GUILayoutOption[0]); tp.Noise.Lacunarity = EditorGUILayout.Slider(tp.Noise.Lacunarity, 1.5f, 2.5f, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("Amplitude", ""), new GUILayoutOption[0]); tp.Noise.Amplitude = EditorGUILayout.Slider(tp.Noise.Amplitude, -10, 10.0f, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("Offset", ""), new GUILayoutOption[0]); tp.Noise.Offset = EditorGUILayout.Slider(tp.Noise.Offset, -10f, 10.0f, new GUILayoutOption[0]); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); }
public void DrawAlphaSelector(TP tp, Color color) { // Draw label Rect position = EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); tp.Alpha.Enabled = GUILayout.Toggle(tp.Alpha.Enabled, new GUIContent()); DrawTitleLabel("Alpha"); EditorGUILayout.EndHorizontal(); Seperator(1); // Settings Color tempColor = GUI.backgroundColor; if (tp.Alpha.Enabled) { // Size slider tp.BrushSize = EditorGUILayout.FloatField(new GUIContent("Size"), tp.BrushSize, new GUILayoutOption[0]); tp.BrushRotation = EditorGUILayout.FloatField(new GUIContent("Angle"), tp.BrushRotation); DrawTooltip(1, "", new string[] { "Press ctrl and drag mouse to rotate the brush", "Press ctrl and drag mouse to rotate the brush" }); position = EditorGUILayout.BeginVertical(); EditorGUILayout.EndVertical(); const int imgSize = 50; const int spacing = 4; float totalSpacing = (float)spacing; position.width = Screen.width - (20.0f + spacing * 2.0f); // Set potition Rect current = position; current.width = current.height = imgSize; current.x += spacing; current.y += spacing; // Get amount of columns int columnCount = (int)((position.width - (2 * spacing)) / (spacing + imgSize)); for (int i = 0; i < tp.Alpha.alphaBrushes.Count; i++) { if (i > 0 && i % columnCount == 0) { // New line totalSpacing += imgSize + spacing; current.x = position.x + spacing; current.y = position.y + totalSpacing; } else if (i != 0) { current.x += imgSize + spacing; } // Set colour, set selected alpha texture if (i == (int)tp.Alpha) { GUI.backgroundColor = color; } else { GUI.backgroundColor = TP.Colors.UnSelectedColor; } if (GUI.Button(current, tp.Alpha.alphaBrushes[i])) { tp.Alpha.selectedAlphaBrush = i; } } GUI.backgroundColor = tempColor; totalSpacing += imgSize + spacing; GUILayout.Space(totalSpacing); // Update button EditorGUILayout.BeginHorizontal(); FlexibleSpace(5); if (GUILayout.Button(new GUIContent("update.."))) { tp.Alpha.Update(); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); // Reset color GUI.color = tempColor; }
internal virtual void OnSceneGUI(TP c) { m_component = c; }
private static bool IsPaintTab(TP tpc) { if (!tpc.Alpha.Enabled) { return false; } switch (tpc.EditingTool) { case EditingTool.Height: break; case EditingTool.Texture: switch (tpc.SplatTool) { case SplatTool.OneTexture: case SplatTool.HeightBased: case SplatTool.AngleBased: case SplatTool.Sharpen: case SplatTool.Blur: return true; } break; case EditingTool.Foliage: return true; case EditingTool.Object: break; } return false; }
public static void DrawNoiseEditor(TP tp, int resolution) { // Draw label EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); tp.Noise.Enabled = GUILayout.Toggle(tp.Noise.Enabled, new GUIContent()); DrawTitleLabel("Noise"); EditorGUILayout.EndHorizontal(); Seperator(1); //tp.Noise.Enabled = EditorGUILayout.ToggleLeft(new GUIContent("Noise"), tp.Noise.Enabled, EditorStyles.boldLabel, new GUILayoutOption[0]); // If noise is enabled if (tp.Noise.Enabled) { // Texture preview Settings const int previewSize = 100; EditorGUILayout.BeginHorizontal(); Rect current = EditorGUILayout.BeginVertical(); // Get texture Texture2D tex = new Texture2D(previewSize, previewSize); tex.hideFlags = HideFlags.HideAndDontSave; // Draw preview texture if (tp.Noise.Texture != null) { tex = tp.Noise.Texture; } current.height = current.width = previewSize; GUI.Label(current, new GUIContent(tex, tex.name)); // Offset current.y += previewSize + 2.0f; current.height = 16.0f; // Draw generate button if (GUI.Button(current, new GUIContent("Generate"))) { //tp.Noise.Generate(new Point(tp.TerrainData.alphamapWidth, tp.TerrainData.alphamapHeight)); tp.Noise.Generate(new Point(resolution, resolution)); } EditorGUILayout.EndVertical(); GUILayout.Space(previewSize + 2.0f); // Settings EditorGUILayout.BeginVertical(); // Draw generate on click checkbox tp.Noise.GenerateOnClick = EditorGUILayout.Toggle(new GUIContent("Generate on click", "Generate new splatmap on mousebutton down"), tp.Noise.GenerateOnClick, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("Scale", "Noise scale"), new GUILayoutOption[0]); tp.Noise.Scale = EditorGUILayout.FloatField(tp.Noise.Scale, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("Octaves", "Amount of iterations applied"), new GUILayoutOption[0]); tp.Noise.Octaves = EditorGUILayout.IntSlider(tp.Noise.Octaves, 1, 10, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("Gain", "Gain of each iteration"), new GUILayoutOption[0]); tp.Noise.Gain = EditorGUILayout.Slider(tp.Noise.Gain, 0.1f, 0.9f, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("Lacunarity", ""), new GUILayoutOption[0]); tp.Noise.Lacunarity = EditorGUILayout.Slider(tp.Noise.Lacunarity, 1.5f, 2.5f, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("Amplitude", ""), new GUILayoutOption[0]); tp.Noise.Amplitude = EditorGUILayout.Slider(tp.Noise.Amplitude, -10, 10.0f, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("Offset", ""), new GUILayoutOption[0]); tp.Noise.Offset = EditorGUILayout.Slider(tp.Noise.Offset, -10f, 10.0f, new GUILayoutOption[0]); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); }
internal override void OnInspectorGUI(TP component) { base.OnInspectorGUI(component); // Set brush projector color GUILayout.Label(new GUIContent("Brush"), EditorStyles.boldLabel); tp_Projector.BrushInactiveColor = EditorGUILayout.ColorField(new GUIContent("Inactive Color"), tp_Projector.BrushInactiveColor); tp_Projector.BrushActiveColor = EditorGUILayout.ColorField(new GUIContent("Active Color"), tp_Projector.BrushActiveColor); component.BrushRotationSensitivity = EditorGUILayout.FloatField(new GUIContent("Rotating sensitivity"), component.BrushRotationSensitivity); EditorGUILayout.BeginHorizontal(); Seperator(1); if (GUILayout.Button("Load Deafault")) { LoadDefault(); } EditorGUILayout.EndHorizontal(); Seperator(3); // Undo GUILayout.Label(new GUIContent("History"), EditorStyles.boldLabel); component.History.Capacity = EditorGUILayout.IntField(new GUIContent("Undo Capacity", "How may time undo can be performed"), component.History.Capacity); Seperator(3); // Save load Settings EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Settings"), EditorStyles.boldLabel); FlexibleSpace(5); if (GUILayout.Button("Save..")) { SaveSettings(); } if (GUILayout.Button("Load..")) { LoadSettings(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("You can save and load your settings \ni.e. Height settings, projector colors"), EditorStyles.label); EditorGUILayout.EndVertical(); Seperator(3); // Save load terrain splat EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Splatmaps"), EditorStyles.boldLabel); FlexibleSpace(5); if (GUILayout.Button("Save..")) { SaveSplatMap(); } if (GUILayout.Button("Load..")) { LoadSplatMap(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]); GUILayout.Label(new GUIContent("NOTE: The process could take \"a few\" seconds; \ndepending on your system, \nsplatmap size and amount of splatmaps.\n\nNOTE: Make sure the loaded splatmap-resolution \nmatches the terrain splatmap-resolution"), EditorStyles.miniLabel); EditorGUILayout.EndVertical(); Seperator(3); GUILayout.Label(new GUIContent("Foliage"), EditorStyles.boldLabel); component.MaxFoliageStrength = EditorGUILayout.IntField(new GUIContent("Max Foliage Strength"), component.MaxFoliageStrength, new GUILayoutOption[0]); component.MaxFoliageStrength = Mathf.Max(1, component.MaxFoliageStrength); Seperator(3); // Hide/Show Paint all EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Paint all Button: "), EditorStyles.boldLabel); component.HidePaintAll = DrawSwitch(component.HidePaintAll, "Show", "Hide"); EditorGUILayout.EndHorizontal(); Seperator(3); // Lock/Unlock splatmap EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Lock Splatmap: "), EditorStyles.boldLabel); component.SplatmapLock = DrawSwitch(component.SplatmapLock, "Unlock", "Lock"); EditorGUILayout.EndHorizontal(); Seperator(3); // Tooltip level EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Tooltip Level: "), EditorStyles.boldLabel); component.TooltipLevel = EditorGUILayout.IntSlider(component.TooltipLevel, 0, TP.MAX_TOOLTIP_LEVEL); EditorGUILayout.EndHorizontal(); DrawTooltip(0, "Tooltip level", new string[] { "No tooltips will be shown at all", "Some tooltips will be shown", "All tooltips will be shown" }); }
internal override void OnInspectorGUI(TP c) { base.OnInspectorGUI(c); // Toolbar GUILayout.BeginHorizontal(); FlexibleSpace(5); component.SplatTool = (SplatTool)GUILayout.Toolbar((int)component.SplatTool, m_toolbarItems, ToolbarOptions(m_toolbarItems.Length)); FlexibleSpace(5); GUILayout.EndHorizontal(); // switch (c.SplatTool) { case SplatTool.OneTexture: DrawTooltip(2, "", new string[] { "Paint with one texture" }); EditorGUILayout.BeginVertical(EditorStyles.helpBox); DrawBrushSettings(); DrawSelectorEditor(m_textureContainer, TextureSelectType.Default); break; case SplatTool.HeightBased: DrawTooltip(2, "", new string[] { "Paint textures based on height" }); EditorGUILayout.BeginVertical(EditorStyles.helpBox); DrawBrushSettings(); DrawHeightEditor(); break; case SplatTool.AngleBased: DrawTooltip(2, "", new string[] { "Paint only the terrain slopes" }); EditorGUILayout.BeginVertical(EditorStyles.helpBox); DrawBrushSettings(); break; case SplatTool.Sharpen: DrawTooltip(2, "", new string[] { "Sharpen texture transitions" }); EditorGUILayout.BeginVertical(EditorStyles.helpBox); DrawBrushSettings(); component.SharpenStrength = EditorGUILayout.Slider(new GUIContent("Sharpen Strength", "Strength of sharpening"), component.SharpenStrength, 1.0f, 10.0f); component.Textures.IsMultiSelect = EditorGUILayout.Toggle(new GUIContent("Use selected textures", "Aplly sharpen to selected textures (disabling this will apply to all textures)"), component.Textures.IsMultiSelect); if (component.Textures.IsMultiSelect) { DrawSelectorEditor(m_cliffContainer, TextureSelectType.Multi); } EditorGUILayout.EndVertical(); DrawAlphaSelector(component, TP.Colors.SelectedPaintTextureColor); PaintAllEditor(); return; case SplatTool.Blur: DrawTooltip(2, "", new string[] { "Smooth texture transitions" }); EditorGUILayout.BeginVertical(EditorStyles.helpBox); DrawBrushSettings(); component.SmoothStrength = EditorGUILayout.IntSlider(new GUIContent("Blur Strength", "Blurring Radius/Strength"), component.SmoothStrength, 1, 8); component.Textures.IsMultiSelect = EditorGUILayout.Toggle(new GUIContent("Use selected textures", "Aplly smoothing to selected textures (disabling this will apply to all textures)"), component.Textures.IsMultiSelect); if (component.Textures.IsMultiSelect) { DrawSelectorEditor(m_cliffContainer, TextureSelectType.Multi); } EditorGUILayout.EndVertical(); DrawAlphaSelector(component, TP.Colors.SelectedPaintTextureColor); PaintAllEditor(); return; default: DrawNone(); return; } EditorGUILayout.EndVertical(); DrawAlphaSelector(component, TP.Colors.SelectedPaintTextureColor); DrawNoiseEditor(component, component.TerrainData.alphamapResolution); DrawSlopeEditor(component, DrawCliffSelectorEditor); PaintAllEditor(); }