private void RenderTileConnectionTypePreviewLabel(Rect previewRect) { string labelText = _settings.TileConnectionType.ToString(); EditorGUILayoutEx.LabelInMiddleOfControlRect(previewRect, labelText, TileConnectionPreviewButtonSize, GetStyleForTileConnectionTypePreviewLabel()); }
private void RenderPrefabPreviewRows() { for (int prefabIndex = 0; prefabIndex < _filteredPrefabs.Count; ++prefabIndex) { // Start a new row? if (prefabIndex % ViewData.NumberOfPrefabsPerRow == 0) { if (prefabIndex != 0) { EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); } // Render the prefab entry Prefab prefab = _filteredPrefabs[prefabIndex]; var previewButtonRenderData = new PrefabPreviewButtonRenderData(); previewButtonRenderData.ExtractFromPrefab(prefab, ViewData.PrefabPreviewScale); EditorGUILayout.BeginVertical(GUILayout.Width(previewButtonRenderData.ButtonWidth)); // Render the prefab preview button EditorGUIColor.Push(prefab == _prefabCategory.ActivePrefab ? ViewData.ActivePrefabTint : Color.white); if (EditorGUILayoutEx.PrefabPreview(prefab, true, previewButtonRenderData)) { ObjectPlacementSettings placementSettings = ObjectPlacementSettings.Get(); if (placementSettings.ObjectPlacementMode == ObjectPlacementMode.DecorPaint && placementSettings.DecorPaintObjectPlacementSettings.DecorPaintMode == DecorPaintMode.Brush && DecorPaintObjectPlacementBrushDatabase.Get().ActiveBrush != null && Event.current.button == (int)MouseButton.Right) { UndoEx.RecordForToolAction(DecorPaintObjectPlacementBrushDatabase.Get().ActiveBrush); DecorPaintObjectPlacementBrushElement brushElement = DecorPaintObjectPlacementBrushDatabase.Get().ActiveBrush.CreateNewElement(); brushElement.Prefab = prefab; Octave3DWorldBuilder.ActiveInstance.RepaintAllEditorWindows(); Octave3DWorldBuilder.ActiveInstance.Inspector.Repaint(); } else if (Octave3DWorldBuilder.ActiveInstance.Inspector.ActiveInspectorGUIIdentifier == InspectorGUIIdentifier.ObjectSelection && AllShortcutCombos.Instance.ReplacePrefabsForSelectedObjects.IsActive()) { ObjectSelection.Get().ReplaceSelectedObjectsWithPrefab(prefab); } else { UndoEx.RecordForToolAction(_prefabCategory); _prefabCategory.SetActivePrefab(prefab); } } EditorGUIColor.Pop(); // Render the prefab name labels if necessary if (ViewData.ShowPrefabNames) { Rect previewRectangle = GUILayoutUtility.GetLastRect(); EditorGUILayoutEx.LabelInMiddleOfControlRect(previewRectangle, prefab.Name, previewButtonRenderData.ButtonHeight, GetStyleForPrefabNameLabel()); } // Render the remove prefab button if (GUILayout.Button(GetRemovePrefabButtonContent())) { UndoEx.RecordForToolAction(_prefabCategory); _prefabCategory.RemoveAndDestroyPrefab(prefab); Octave3DWorldBuilder.ActiveInstance.Inspector.Repaint(); } EditorGUILayout.EndVertical(); } // End the last row (if any) if (_filteredPrefabs.Count != 0) { EditorGUILayout.EndHorizontal(); } }