private static void DrawBrushTile(TerrainGenerator instance, Vector2 tileSize, int i) { List <ColorPainter.BrushSettings> brushes = instance.ColorPainter.Settings.Palette; EditorGUILayout.BeginVertical(); Rect buttonRect = EditorGUILayout.GetControlRect(GUILayout.Width(tileSize.x), GUILayout.Height(tileSize.y)); EditorGUIUtility.AddCursorRect(buttonRect, MouseCursor.Link); if (i < brushes.Count) { Vector2 contextButtonSize = new Vector2(15, 10); Vector2 contextButtonPosition = new Vector2( buttonRect.x + buttonRect.width - contextButtonSize.x, buttonRect.y); Rect contextButtonRect = new Rect(contextButtonPosition, contextButtonSize); if (GUI.Button(contextButtonRect, "")) { DisplayContextMenuForBrush(contextButtonRect, instance, i); } Color baseColor = ColorLibrary.GetColor(brushes[i].color, 1); float alpha = brushes[i].color.a; EditorGUI.DrawRect(buttonRect, baseColor); Rect alphaBgRect = new Rect(buttonRect.x, buttonRect.max.y - 3, buttonRect.width, 3); Rect alphaRect = new Rect(buttonRect.x, buttonRect.max.y - 3, buttonRect.width * alpha, 3); EditorGUI.DrawRect(alphaBgRect, Color.black); EditorGUI.DrawRect(alphaRect, Color.white); GUIContent content = new GUIContent(string.Empty, brushes[i].ToString()); if (GUI.Button(buttonRect, content, GUIStyle.none)) { instance.ColorPainter.ApplyBrushFromPaletteAtIndex(i); } GUIStyle contextLabelStyle = baseColor.grayscale >= 0.5f ? GuiStyleUtilities.RightAlignedGrayMiniLabel : GuiStyleUtilities.RightAlignedWhiteMiniLabel; EditorGUI.LabelField(contextButtonRect, "••• ", contextLabelStyle); EditorGUILayout.LabelField(brushes[i].name, EditorCommon.CenteredLabel, GUILayout.MaxWidth(tileSize.x)); } EditorGUILayout.EndVertical(); }
private void DrawCombinationsBounds() { #if UNITY_EDITOR if (!Settings.drawCombinationsBounds) { return; } Handles.color = ColorLibrary.GetColor(Color.yellow, 0.5f); List <GameObject> prefabs = Settings.GetPrefabs(); for (int prefabIndex = 0; prefabIndex < prefabs.Count; ++prefabIndex) { Transform[] combinations = GetCombinations(prefabs[prefabIndex]); for (int combIndex = 0; combIndex < combinations.Length; ++combIndex) { MeshRenderer[] mr = combinations[combIndex].GetComponentsInChildren <MeshRenderer>(); for (int mrIndex = 0; mrIndex < mr.Length; ++mrIndex) { Bounds b = mr[mrIndex].bounds; Handles.DrawWireCube(b.center, b.size); } } } #endif }