Ruined Town Sectors
This commit is contained in:
@@ -8,6 +8,7 @@ public class HeaderCreatorWindow : EditorWindow
|
||||
private string objectName = "New GameObject";
|
||||
private string headerDescription = "";
|
||||
private int selectedIdentifier = 1;
|
||||
private bool resetTransform = true;
|
||||
|
||||
private static HierarchyDecoratorSettings settings;
|
||||
private Vector2 scrollPosition;
|
||||
@@ -18,8 +19,7 @@ public class HeaderCreatorWindow : EditorWindow
|
||||
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);
|
||||
window.minSize = new Vector2(320, 400); // Jeszcze trochê wiêksze
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
@@ -28,7 +28,7 @@ public class HeaderCreatorWindow : EditorWindow
|
||||
|
||||
if (settings == null)
|
||||
{
|
||||
Debug.LogError("HierarchyDecoratorSettings not found!");
|
||||
Debug.LogError("Settings not found!");
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
@@ -48,118 +48,128 @@ public class HeaderCreatorWindow : EditorWindow
|
||||
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.LabelField("Description (Optional)", EditorStyles.miniBoldLabel);
|
||||
headerDescription = EditorGUILayout.TextField(headerDescription);
|
||||
|
||||
EditorGUILayout.Space(5);
|
||||
resetTransform = EditorGUILayout.ToggleLeft("Reset Transform (Pos 0, Scale 1)", resetTransform);
|
||||
|
||||
if (GUILayout.Button("Create Simple Empty (using Name only)", GUILayout.Height(30)))
|
||||
EditorGUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Type 1: Colored Header", EditorStyles.boldLabel);
|
||||
|
||||
if (settings.colorSchemes.Count > 0)
|
||||
{
|
||||
CreateSimpleEmptyObject();
|
||||
DrawColorSelectionGrid();
|
||||
EditorGUILayout.Space(2);
|
||||
if (GUILayout.Button("Create Colored Header", GUILayout.Height(30)))
|
||||
{
|
||||
CreateHeaderObject();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Type 2: Separators", EditorStyles.boldLabel);
|
||||
|
||||
// PRZYCISK SEKCJI (SUBTELNY TEKST)
|
||||
GUI.backgroundColor = new Color(0.8f, 0.8f, 0.8f);
|
||||
if (GUILayout.Button("Create Section Header (Subtle Text)", GUILayout.Height(25)))
|
||||
{
|
||||
CreateSectionHeader(); // Nowa funkcja
|
||||
Close();
|
||||
}
|
||||
|
||||
// ZMIANA: Dodajemy nowy przycisk do tworzenia separatora "= Clean"
|
||||
EditorGUILayout.Space(10); // Dodajemy trochê wiêcej miejsca
|
||||
EditorGUILayout.Space(2);
|
||||
|
||||
// Ustawiamy inny kolor t³a dla tego specjalnego przycisku, aby siê wyró¿nia³
|
||||
// PRZYCISK CZYSTEGO SEPARATORA
|
||||
GUI.backgroundColor = new Color(0.4f, 0.4f, 0.45f);
|
||||
|
||||
if (GUILayout.Button("Create Clean Separator", GUILayout.Height(30)))
|
||||
if (GUILayout.Button("Create Clean Separator (Empty)", GUILayout.Height(25)))
|
||||
{
|
||||
CreateCleanSeparator();
|
||||
Close();
|
||||
}
|
||||
|
||||
// WA¯NE: Resetujemy kolor t³a do domyœlnego, aby nie wp³ywa³ na inne elementy GUI
|
||||
GUI.backgroundColor = Color.white;
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
if (GUILayout.Button("Create Simple Empty", GUILayout.Height(20)))
|
||||
{
|
||||
CreateSimpleEmptyObject();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawColorSelectionGrid()
|
||||
{
|
||||
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Height(80));
|
||||
// ... (bez zmian) ...
|
||||
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Height(60));
|
||||
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)))
|
||||
if (GUILayout.Button(scheme.identifier.ToString(), buttonStyle, GUILayout.MinWidth(40), GUILayout.Height(25)))
|
||||
{
|
||||
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;
|
||||
}
|
||||
if (buttonsInRow >= columns) { GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); buttonsInRow = 0; }
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
private void ApplyTransformReset(GameObject obj)
|
||||
{
|
||||
if (resetTransform)
|
||||
{
|
||||
obj.transform.localPosition = Vector3.zero;
|
||||
obj.transform.localRotation = Quaternion.identity;
|
||||
obj.transform.localScale = Vector3.one;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
if (!string.IsNullOrEmpty(headerDescription.Trim())) finalName += $"={headerDescription.Trim()}";
|
||||
CreateObject(finalName, "Create Custom 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;
|
||||
CreateObject(objectName, "Create Simple Empty");
|
||||
}
|
||||
|
||||
// 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;
|
||||
CreateObject("= Clean", "Create Clean Separator");
|
||||
}
|
||||
|
||||
// --- NOWA FUNKCJA: TWORZENIE SEKCJI # ---
|
||||
private void CreateSectionHeader()
|
||||
{
|
||||
// Tworzymy nazwê zaczynaj¹c¹ siê od #
|
||||
string name = objectName.Trim();
|
||||
if (string.IsNullOrEmpty(name)) name = "SECTION";
|
||||
|
||||
string finalName = $"# {name}";
|
||||
CreateObject(finalName, "Create Section Header");
|
||||
}
|
||||
|
||||
private void CreateObject(string name, string undoName)
|
||||
{
|
||||
GameObject obj = new GameObject(name);
|
||||
Undo.RegisterCreatedObjectUndo(obj, undoName);
|
||||
GameObjectUtility.SetParentAndAlign(obj, Selection.activeObject as GameObject);
|
||||
ApplyTransformReset(obj);
|
||||
Selection.activeObject = obj;
|
||||
}
|
||||
|
||||
private void InitializeButtonStyles()
|
||||
|
||||
Reference in New Issue
Block a user