This commit is contained in:
szczuras4
2025-09-22 18:02:22 +02:00
parent 2d8a3b6942
commit 707eb89cf7
13 changed files with 1199 additions and 818 deletions

View File

@@ -0,0 +1,47 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f046b28826899834f925498b5f90bf2d, type: 3}
m_Name: PrefabBrowserDB
m_EditorClassIdentifier:
groups:
- groupName: Trees
groupColor: {r: 0.38679248, g: 0.1085675, b: 0, a: 1}
useLightText: 1
prefabs: []
- groupName: Stones
groupColor: {r: 0.2924528, g: 0, b: 0, a: 1}
useLightText: 1
prefabs:
- {fileID: 3729385275159174759, guid: b83a40fdffe995c4d8c7ba482fb4b2b8, type: 3}
- {fileID: 6550434966018730688, guid: 3ef32dcb7e900c245b48572d43b140b4, type: 3}
- {fileID: 2959732555524133462, guid: 4f8faff92d8e4ed48a9066ebcbb0c713, type: 3}
- {fileID: 8279010982994336710, guid: 63c806cd13577c540912cd97173b4e42, type: 3}
- {fileID: 1953575432603607144, guid: b64493b656965604b9e7eb94f190ee24, type: 3}
- {fileID: 6259510873288837657, guid: b7dfcff84cbf1254fb32b287ec9e8ea7, type: 3}
- {fileID: 8501429591298181761, guid: c42346a06a7af8c4f9befe3fd4fa24e9, type: 3}
- {fileID: 5285407229512777518, guid: 7b8645300baedc6428d90bcb18db3a06, type: 3}
- groupName: Brushes
groupColor: {r: 0.3584906, g: 0.06858081, b: 0, a: 1}
useLightText: 1
prefabs: []
- groupName: Destructable
groupColor: {r: 0.5377358, g: 0, b: 0, a: 1}
useLightText: 1
prefabs: []
- groupName: New Group
groupColor: {r: 0.3, g: 0.3, b: 0.3, a: 1}
useLightText: 1
prefabs: []
- groupName: New Group
groupColor: {r: 0.3, g: 0.3, b: 0.3, a: 1}
useLightText: 1
prefabs: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d8a956128c0de73449591ca4eefeb612
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -64,9 +64,9 @@ public static class CustomHierarchyDecorator
// Funkcja rysuj¹ca niestandardowy nag³ówek
private static void DrawCustomHeader(Rect rect, GameObject obj)
{
if (obj.name.Trim() == "= Clean")
if (obj.name.Trim().StartsWith("= Clean")) // <-- ZMIANA TUTAJ
{
// Jeœli jest "Clean", rysujemy tylko t³o
// Jeœli nazwa zaczyna siê od "Clean", rysujemy tylko t³o
EditorGUI.DrawRect(rect, settings.cleanBackgroundColor);
return;
}
@@ -144,7 +144,7 @@ public static class CustomHierarchyDecorator
EditorApplication.delayCall += () =>
{
GameObject[] cleanSeparators = Object.FindObjectsByType<GameObject>(FindObjectsInactive.Include, FindObjectsSortMode.None)
.Where(obj => obj.name.Trim() == "= Clean")
.Where(obj => obj.name.Trim().StartsWith("= Clean")) // <-- ZMIANA TUTAJ
.ToArray();
foreach (var cleanObj in cleanSeparators)

View File

@@ -0,0 +1,190 @@
using UnityEditor;
using UnityEngine;
using System.Linq;
using System.Collections.Generic;
public class HeaderCreatorWindow : EditorWindow
{
private string objectName = "New GameObject";
private string headerDescription = "";
private int selectedIdentifier = 1;
private static HierarchyDecoratorSettings settings;
private Vector2 scrollPosition;
private Dictionary<int, GUIStyle> colorStyles;
[MenuItem("GameObject/Create Custom Header", false, 0)]
[MenuItem("GameObject/Create Empty", false, 0)]
public static void ShowWindow()
{
HeaderCreatorWindow window = GetWindow<HeaderCreatorWindow>(true, "Create Object");
// ZMIANA: Zwiêkszamy minimaln¹ wysokoœæ okna, aby zmieœci³ siê nowy przycisk
window.minSize = new Vector2(320, 340);
}
private void OnEnable()
{
settings = AssetDatabase.LoadAssetAtPath<HierarchyDecoratorSettings>("Assets/Scripts/Editor/HierarchyDecoratorSettings.asset");
if (settings == null)
{
Debug.LogError("HierarchyDecoratorSettings not found!");
Close();
return;
}
if (settings.colorSchemes.Count > 0)
{
selectedIdentifier = settings.colorSchemes.First().identifier;
InitializeButtonStyles();
}
}
private void OnGUI()
{
if (settings == null) return;
EditorGUILayout.LabelField("Create a new object", EditorStyles.boldLabel);
objectName = EditorGUILayout.TextField("Name", objectName);
EditorGUILayout.Space(10);
EditorGUILayout.LabelField("For Custom Header:", EditorStyles.miniBoldLabel);
headerDescription = EditorGUILayout.TextField("Description (Optional)", headerDescription);
if (settings.colorSchemes.Count == 0)
{
EditorGUILayout.HelpBox("No color schemes defined in HierarchyDecoratorSettings. You can only create a simple empty object.", MessageType.Warning);
}
else
{
EditorGUILayout.LabelField("Color Scheme", EditorStyles.boldLabel);
DrawColorSelectionGrid();
}
EditorGUILayout.Space();
GUI.enabled = settings.colorSchemes.Count > 0;
if (GUILayout.Button("Create Custom Header", GUILayout.Height(35)))
{
CreateHeaderObject();
Close();
}
GUI.enabled = true;
EditorGUILayout.Space(5);
if (GUILayout.Button("Create Simple Empty (using Name only)", GUILayout.Height(30)))
{
CreateSimpleEmptyObject();
Close();
}
// ZMIANA: Dodajemy nowy przycisk do tworzenia separatora "= Clean"
EditorGUILayout.Space(10); // Dodajemy trochê wiêcej miejsca
// Ustawiamy inny kolor t³a dla tego specjalnego przycisku, aby siê wyró¿nia³
GUI.backgroundColor = new Color(0.4f, 0.4f, 0.45f);
if (GUILayout.Button("Create Clean Separator", GUILayout.Height(30)))
{
CreateCleanSeparator();
Close();
}
// WA¯NE: Resetujemy kolor t³a do domyœlnego, aby nie wp³ywa³ na inne elementy GUI
GUI.backgroundColor = Color.white;
}
private void DrawColorSelectionGrid()
{
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Height(80));
int columns = 5;
int buttonsInRow = 0;
GUILayout.BeginHorizontal();
foreach (var scheme in settings.colorSchemes)
{
GUIStyle buttonStyle = colorStyles[scheme.identifier];
string buttonText = scheme.identifier.ToString();
if (GUILayout.Button(buttonText, buttonStyle, GUILayout.MinWidth(40), GUILayout.Height(30)))
{
selectedIdentifier = scheme.identifier;
}
if (Event.current.type == EventType.Repaint && scheme.identifier == selectedIdentifier)
{
Rect buttonRect = GUILayoutUtility.GetLastRect();
EditorGUI.DrawRect(buttonRect, new Color(0.5f, 0.5f, 0.5f, 0.4f));
}
buttonsInRow++;
if (buttonsInRow >= columns)
{
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
buttonsInRow = 0;
}
}
GUILayout.EndHorizontal();
EditorGUILayout.EndScrollView();
}
private void CreateHeaderObject()
{
string finalName = $"{selectedIdentifier}={objectName.Trim()}";
if (!string.IsNullOrEmpty(headerDescription.Trim()))
{
finalName += $"={headerDescription.Trim()}";
}
GameObject header = new GameObject(finalName);
Undo.RegisterCreatedObjectUndo(header, "Create Custom Header");
GameObjectUtility.SetParentAndAlign(header, Selection.activeObject as GameObject);
Selection.activeObject = header;
}
private void CreateSimpleEmptyObject()
{
GameObject emptyObj = new GameObject(objectName);
Undo.RegisterCreatedObjectUndo(emptyObj, "Create Simple Empty Object");
GameObjectUtility.SetParentAndAlign(emptyObj, Selection.activeObject as GameObject);
Selection.activeObject = emptyObj;
}
// ZMIANA: Nowa funkcja do tworzenia separatora "= Clean"
private void CreateCleanSeparator()
{
// Nazwa jest sta³a i nie zale¿y od pól w oknie
GameObject cleanSeparator = new GameObject("= Clean");
Undo.RegisterCreatedObjectUndo(cleanSeparator, "Create Clean Separator");
GameObjectUtility.SetParentAndAlign(cleanSeparator, Selection.activeObject as GameObject);
Selection.activeObject = cleanSeparator;
}
private void InitializeButtonStyles()
{
colorStyles = new Dictionary<int, GUIStyle>();
foreach (var scheme in settings.colorSchemes)
{
GUIStyle style = new GUIStyle(EditorStyles.miniButton);
Texture2D backgroundTexture = MakeTex(1, 1, scheme.activeBackgroundColor);
style.normal.background = backgroundTexture;
style.active.background = backgroundTexture;
style.normal.textColor = scheme.activeTextColor;
style.alignment = TextAnchor.MiddleCenter;
style.fontStyle = FontStyle.Bold;
colorStyles.Add(scheme.identifier, style);
}
}
private Texture2D MakeTex(int width, int height, Color col)
{
Color[] pix = new Color[width * height];
for (int i = 0; i < pix.Length; ++i) pix[i] = col;
Texture2D result = new Texture2D(width, height);
result.SetPixels(pix);
result.Apply();
return result;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5113ff53def7bbb4a9b1c0d790d0809e

View File

@@ -0,0 +1,17 @@
using UnityEngine;
using System.Collections.Generic;
[System.Serializable]
public class PrefabGroup
{
public string groupName;
public Color groupColor = new Color(0.3f, 0.3f, 0.3f, 1f);
public bool useLightText = true;
public List<GameObject> prefabs = new List<GameObject>();
}
[CreateAssetMenu(fileName = "PrefabBrowserDB", menuName = "Tools/Prefab Browser Database")]
public class PrefabBrowserDatabase : ScriptableObject
{
public List<PrefabGroup> groups = new List<PrefabGroup>();
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f046b28826899834f925498b5f90bf2d

View File

@@ -0,0 +1,352 @@
using UnityEditor;
using UnityEngine;
using System.Linq;
using System.Collections.Generic;
public class PrefabBrowserWindow : EditorWindow
{
private PrefabBrowserDatabase database;
private int selectedGroupIndex = -1;
private string newGroupName = "New Group";
private Vector2 leftPaneScroll;
private Vector2 rightPaneScroll;
private GUIStyle frameStyle;
private float iconSize = 80f;
private string searchFilter = "";
private const float ListViewThreshold = 61f;
private GameObject selectedPrefab = null;
private void OnEnable()
{
LoadDatabase();
iconSize = EditorPrefs.GetFloat("PrefabBrowser_IconSize", 80f);
}
private void OnFocus()
{
LoadDatabase();
Repaint();
}
[MenuItem("Tools/Prefab Browser")]
public static void ShowWindow()
{
GetWindow<PrefabBrowserWindow>("Prefab Browser");
}
private void LoadDatabase()
{
string[] guids = AssetDatabase.FindAssets("t:PrefabBrowserDatabase");
if (guids.Length > 0)
{
string path = AssetDatabase.GUIDToAssetPath(guids[0]);
database = AssetDatabase.LoadAssetAtPath<PrefabBrowserDatabase>(path);
}
else
{
database = null;
}
}
private void OnGUI()
{
if (database == null)
{
EditorGUILayout.HelpBox("Prefab Browser Database not found. Please create one via:\nAssets -> Create -> Tools -> Prefab Browser Database", MessageType.Warning);
if (GUILayout.Button("Try to Reload Database")) LoadDatabase();
return;
}
if (frameStyle == null)
{
frameStyle = new GUIStyle(GUI.skin.box);
frameStyle.margin = new RectOffset(4, 4, 0, 5);
frameStyle.padding = new RectOffset(2, 2, 2, 2);
}
EditorGUILayout.BeginHorizontal();
DrawLeftPane();
DrawRightPane();
EditorGUILayout.EndHorizontal();
}
private void DrawLeftPane()
{
EditorGUILayout.BeginVertical(GUI.skin.box, GUILayout.Width(200), GUILayout.ExpandHeight(true));
EditorGUILayout.LabelField("Prefab Groups", EditorStyles.boldLabel);
leftPaneScroll = EditorGUILayout.BeginScrollView(leftPaneScroll);
if (database.groups != null)
{
for (int i = 0; i < database.groups.Count; i++)
{
var group = database.groups[i];
EditorGUILayout.BeginVertical(frameStyle);
{
Color rowBackgroundColor = (i == selectedGroupIndex) ? new Color(0.24f, 0.48f, 0.85f) : group.groupColor;
Color textColor = (i == selectedGroupIndex) ? Color.white : (group.useLightText ? Color.white : Color.black);
Rect coloredBarRect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(22));
EditorGUI.DrawRect(coloredBarRect, rowBackgroundColor);
GUIStyle labelStyle = new GUIStyle(EditorStyles.label) { normal = { textColor = textColor } };
labelStyle.fontStyle = FontStyle.Bold;
labelStyle.padding.left = 5;
GUI.Label(new Rect(coloredBarRect.x, coloredBarRect.y, coloredBarRect.width - 25, coloredBarRect.height), group.groupName, labelStyle);
Rect settingsIconRect = new Rect(coloredBarRect.x + coloredBarRect.width - 22, coloredBarRect.y + 2, 18, 18);
GUI.DrawTexture(settingsIconRect, EditorGUIUtility.IconContent("d_Settings").image);
Event currentEvent = Event.current;
if (currentEvent.type == EventType.MouseDown && currentEvent.button == 0)
{
if (settingsIconRect.Contains(currentEvent.mousePosition))
{
PrefabGroupSettingsWindow.ShowAsDropDown(settingsIconRect, group, database);
currentEvent.Use();
}
else if (coloredBarRect.Contains(currentEvent.mousePosition))
{
if (selectedGroupIndex != i)
{
selectedPrefab = null;
}
selectedGroupIndex = i;
Repaint();
currentEvent.Use();
}
}
}
EditorGUILayout.EndVertical();
}
}
EditorGUILayout.EndScrollView();
EditorGUILayout.Space();
EditorGUILayout.LabelField("Create New Group:", EditorStyles.miniBoldLabel);
newGroupName = EditorGUILayout.TextField(newGroupName);
if (GUILayout.Button("Add Group") && !string.IsNullOrWhiteSpace(newGroupName))
{
database.groups.Add(new PrefabGroup { groupName = newGroupName });
newGroupName = "New Group";
EditorUtility.SetDirty(database);
AssetDatabase.SaveAssets();
}
EditorGUILayout.EndVertical();
}
private void DrawRightPane()
{
EditorGUILayout.BeginVertical(GUI.skin.box, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
if (selectedGroupIndex < 0 || database.groups == null || selectedGroupIndex >= database.groups.Count)
{
EditorGUILayout.LabelField("Select a group from the left panel.", EditorStyles.centeredGreyMiniLabel);
EditorGUILayout.EndVertical();
return;
}
var selectedGroup = database.groups[selectedGroupIndex];
Color headerBgColor = selectedGroup.groupColor;
Color headerTextColor = selectedGroup.useLightText ? Color.white : Color.black;
GUIStyle headerStyle = new GUIStyle(EditorStyles.boldLabel) { alignment = TextAnchor.MiddleCenter, padding = new RectOffset(5, 5, 5, 5) };
Texture2D headerBgTexture = new Texture2D(1, 1);
headerBgTexture.SetPixel(0, 0, headerBgColor);
headerBgTexture.Apply();
headerStyle.normal.background = headerBgTexture;
headerStyle.normal.textColor = headerTextColor;
GUILayout.Label($"Prefabs in '{selectedGroup.groupName}'", headerStyle, GUILayout.ExpandWidth(true));
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
searchFilter = EditorGUILayout.TextField(searchFilter, EditorStyles.toolbarSearchField);
if (GUILayout.Button("X", EditorStyles.toolbarButton, GUILayout.Width(22)))
{
searchFilter = "";
GUI.FocusControl(null);
}
EditorGUILayout.EndHorizontal();
rightPaneScroll = EditorGUILayout.BeginScrollView(rightPaneScroll);
var filteredPrefabs = selectedGroup.prefabs.Where(p => p != null &&
(string.IsNullOrWhiteSpace(searchFilter) || p.name.ToLowerInvariant().Contains(searchFilter.ToLowerInvariant()))
).ToList();
if (iconSize < ListViewThreshold)
{
foreach (var prefab in filteredPrefabs)
{
DrawPrefabListItem(prefab, selectedGroup);
}
}
else
{
float cellWidth = iconSize + 20;
int gridCols = Mathf.Max(1, Mathf.FloorToInt((position.width - 220) / cellWidth));
if (filteredPrefabs.Count > 0)
{
for (int i = 0; i < filteredPrefabs.Count; i += gridCols)
{
EditorGUILayout.BeginHorizontal();
for (int j = 0; j < gridCols; j++)
{
if (i + j < filteredPrefabs.Count)
{
DrawPrefabIcon(filteredPrefabs[i + j], selectedGroup, iconSize);
}
else GUILayout.Space(cellWidth);
}
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
}
}
}
EditorGUILayout.EndScrollView();
DrawBottomControls();
EditorGUILayout.EndVertical();
}
private void DrawBottomControls()
{
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
float newIconSize = GUILayout.HorizontalSlider(iconSize, 60f, 120f, GUILayout.Width(150));
if (newIconSize != iconSize)
{
iconSize = newIconSize;
EditorPrefs.SetFloat("PrefabBrowser_IconSize", iconSize);
}
EditorGUILayout.EndHorizontal();
Rect dropArea = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));
GUI.Box(dropArea, "Drag & Drop Prefabs Here");
HandleDragAndDrop(dropArea);
}
// --- NOWA FUNKCJA POMOCNICZA: Rysuje ramkê wokó³ prostok¹ta ---
private void DrawSelectionFrame(Rect rect, Color color, int thickness)
{
// Rysujemy 4 prostok¹ty (góra, dó³, lewo, prawo), aby stworzyæ ramkê
// U¿ywamy bia³ej tekstury i zabarwiamy j¹ na po¿¹dany kolor - to standardowa i wydajna technika w edytorze.
Texture2D texture = EditorGUIUtility.whiteTexture;
GUI.color = color;
GUI.DrawTexture(new Rect(rect.x, rect.y, rect.width, thickness), texture); // Góra
GUI.DrawTexture(new Rect(rect.x, rect.yMax - thickness, rect.width, thickness), texture); // Dó³
GUI.DrawTexture(new Rect(rect.x, rect.y, thickness, rect.height), texture); // Lewo
GUI.DrawTexture(new Rect(rect.xMax - thickness, rect.y, thickness, rect.height), texture); // Prawo
GUI.color = Color.white; // Resetujemy kolor do domyœlnego
}
private void DrawPrefabListItem(GameObject prefab, PrefabGroup group)
{
EditorGUILayout.BeginHorizontal(GUI.skin.box);
Texture icon = AssetPreview.GetMiniThumbnail(prefab);
GUILayout.Label(icon, GUILayout.Width(20), GUILayout.Height(20));
EditorGUILayout.LabelField(prefab.name);
GUILayout.FlexibleSpace();
if (GUILayout.Button("Remove", GUILayout.Width(60)))
{
group.prefabs.Remove(prefab);
EditorUtility.SetDirty(database);
}
EditorGUILayout.EndHorizontal();
Rect itemRect = GUILayoutUtility.GetLastRect();
// --- ZMIANA: Rysujemy ramkê zamiast pó³przezroczystego t³a ---
if (selectedPrefab == prefab)
{
DrawSelectionFrame(itemRect, new Color(0.24f, 0.48f, 0.85f, 1f), 1); // Cieñsza ramka dla listy
}
Event currentEvent = Event.current;
// Rozdzielamy logikê: klikniêcie zaznacza, przeci¹ganie rozpoczyna siê, gdy mysz jest wciœniêta i siê rusza
if (itemRect.Contains(currentEvent.mousePosition))
{
if (currentEvent.type == EventType.MouseDown && currentEvent.button == 0)
{
selectedPrefab = prefab;
Repaint();
currentEvent.Use();
}
if (currentEvent.type == EventType.MouseDrag && currentEvent.button == 0 && selectedPrefab == prefab)
{
DragAndDrop.PrepareStartDrag();
DragAndDrop.objectReferences = new Object[] { prefab };
DragAndDrop.StartDrag(prefab.name);
currentEvent.Use();
}
}
}
private void DrawPrefabIcon(GameObject prefab, PrefabGroup group, float currentIconSize)
{
if (prefab == null) return;
float cellWidth = currentIconSize + 20;
EditorGUILayout.BeginVertical(GUILayout.Width(cellWidth));
Texture2D preview = AssetPreview.GetAssetPreview(prefab) ?? AssetPreview.GetMiniTypeThumbnail(typeof(GameObject));
Rect previewRect = GUILayoutUtility.GetRect(currentIconSize, currentIconSize);
GUI.Box(previewRect, preview);
// --- ZMIANA: Rysujemy ramkê zamiast pó³przezroczystego t³a ---
if (selectedPrefab == prefab)
{
DrawSelectionFrame(previewRect, new Color(0.24f, 0.48f, 0.85f, 1f), 2); // Grubsza ramka dla siatki
}
Event currentEvent = Event.current;
// Rozdzielamy logikê: klikniêcie zaznacza, przeci¹ganie rozpoczyna siê, gdy mysz jest wciœniêta i siê rusza
if (previewRect.Contains(currentEvent.mousePosition))
{
if (currentEvent.type == EventType.MouseDown && currentEvent.button == 0)
{
selectedPrefab = prefab;
Repaint();
currentEvent.Use();
}
if (currentEvent.type == EventType.MouseDrag && currentEvent.button == 0 && selectedPrefab == prefab)
{
DragAndDrop.PrepareStartDrag();
DragAndDrop.objectReferences = new Object[] { prefab };
DragAndDrop.StartDrag(prefab.name);
currentEvent.Use();
}
}
EditorGUILayout.LabelField(prefab.name, EditorStyles.miniLabel, GUILayout.Width(currentIconSize));
if (GUILayout.Button("Remove", EditorStyles.miniButton))
{
group.prefabs.Remove(prefab);
EditorUtility.SetDirty(database);
}
EditorGUILayout.EndVertical();
}
private void HandleDragAndDrop(Rect dropArea)
{
Event currentEvent = Event.current;
if (currentEvent.type != EventType.DragUpdated && currentEvent.type != EventType.DragPerform) return;
if (!dropArea.Contains(currentEvent.mousePosition)) return;
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
if (currentEvent.type == EventType.DragPerform)
{
DragAndDrop.AcceptDrag();
var selectedPrefabs = DragAndDrop.objectReferences
.OfType<GameObject>()
.Where(go => PrefabUtility.IsPartOfPrefabAsset(go) && !database.groups[selectedGroupIndex].prefabs.Contains(go));
database.groups[selectedGroupIndex].prefabs.AddRange(selectedPrefabs);
EditorUtility.SetDirty(database);
}
currentEvent.Use();
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 37b40567119369f4f9f57bbe0875c495

View File

@@ -0,0 +1,89 @@
using UnityEditor;
using UnityEngine;
public class PrefabGroupSettingsWindow : EditorWindow
{
private PrefabGroup targetGroup;
private PrefabBrowserDatabase database;
private string tempGroupName;
private Color tempGroupColor;
private bool tempUseLightText;
// NOWA METODA: Tworzy okno jako elegancki dropdown pod przyciskiem.
public static void ShowAsDropDown(Rect buttonRect, PrefabGroup groupToEdit, PrefabBrowserDatabase db)
{
PrefabGroupSettingsWindow window = CreateInstance<PrefabGroupSettingsWindow>();
// Ustawiamy docelow¹ grupê dla tej konkretnej instancji okna
window.SetTarget(groupToEdit, db);
// Ustawiamy rozmiar naszego dropdownu
Vector2 windowSize = new Vector2(250, 150);
window.position = new Rect(buttonRect.x, buttonRect.yMax, 0, 0); // Pozycja pocz¹tkowa
// Wyœwietlamy okno
window.ShowAsDropDown(buttonRect, windowSize);
}
// Metoda, która inicjalizuje dane dla tego konkretnego okna.
private void SetTarget(PrefabGroup group, PrefabBrowserDatabase db)
{
targetGroup = group;
database = db;
if (targetGroup != null)
{
tempGroupName = targetGroup.groupName;
tempGroupColor = targetGroup.groupColor;
tempUseLightText = targetGroup.useLightText;
}
}
private void OnGUI()
{
if (targetGroup == null)
{
Close();
return;
}
// Dodajemy trochê marginesu, ¿eby kontrolki nie by³y przyklejone do krawêdzi
EditorGUILayout.BeginVertical(new GUIStyle { padding = new RectOffset(10, 10, 10, 10) });
EditorGUILayout.LabelField("Edit Group", EditorStyles.boldLabel);
EditorGUILayout.Space(5);
tempGroupName = EditorGUILayout.TextField("Group Name", tempGroupName);
tempGroupColor = EditorGUILayout.ColorField("Group Color", tempGroupColor);
tempUseLightText = EditorGUILayout.Toggle("Use Light Text", tempUseLightText);
EditorGUILayout.Space(10);
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Save"))
{
targetGroup.groupName = tempGroupName;
targetGroup.groupColor = tempGroupColor;
targetGroup.useLightText = tempUseLightText;
EditorUtility.SetDirty(database);
AssetDatabase.SaveAssets();
Close();
}
if (GUILayout.Button("Delete"))
{
if (EditorUtility.DisplayDialog("Delete Group", $"Are you sure you want to permanently delete the group '{targetGroup.groupName}'?", "Yes, Delete", "Cancel"))
{
database.groups.Remove(targetGroup);
EditorUtility.SetDirty(database);
AssetDatabase.SaveAssets();
Close();
}
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.EndVertical();
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8bf24d05fa260d44a9c319d6bd7cc730

View File

@@ -65,11 +65,11 @@ Material:
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BlendOp: 2
- _BlendOp: 0
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _DstBlend: 1
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1