using UnityEditor; using UnityEngine; using System.Collections.Generic; public class PuzzleChainEditorWindow : EditorWindow { private List puzzleSteps = new List(); private Dictionary> dependencyGraph; private Vector2 scrollPos; private const int INDENT_SIZE = 24; [MenuItem("Tools/Puzzle Chain Editor")] public static void ShowWindow() { var window = GetWindow("Puzzle Chain Editor"); window.minSize = new Vector2(600, 400); window.maxSize = new Vector2(1200, 800); window.position = new Rect(100, 100, 700, 500); // Reasonable default size and position } private void OnEnable() { LoadPuzzleSteps(); ProcessPuzzleChains(); } private void LoadPuzzleSteps() { puzzleSteps.Clear(); string[] guids = AssetDatabase.FindAssets("t:PuzzleStepSO", new[] { "Assets/Data/Puzzles" }); foreach (var guid in guids) { var path = AssetDatabase.GUIDToAssetPath(guid); var step = AssetDatabase.LoadAssetAtPath(path); if (step != null) puzzleSteps.Add(step); } } private void ProcessPuzzleChains() { dependencyGraph = PuzzleGraphUtility.BuildDependencyGraph(puzzleSteps); } private void OnGUI() { EditorGUILayout.LabelField("Puzzle Chain Visualization", EditorStyles.boldLabel); if (puzzleSteps.Count == 0) { EditorGUILayout.HelpBox("No PuzzleStepSO assets found in Assets/Data/Puzzles.", MessageType.Warning); return; } scrollPos = EditorGUILayout.BeginScrollView(scrollPos); var initialSteps = PuzzleGraphUtility.FindInitialSteps(dependencyGraph); foreach (var step in initialSteps) { EditorGUILayout.BeginVertical("box"); EditorGUILayout.LabelField($"Step Path: {step.displayName} ({step.stepId})", EditorStyles.largeLabel); GUILayout.Space(6); DrawStepTree(step, 0); EditorGUILayout.EndVertical(); GUILayout.Space(12); // Space between step paths } EditorGUILayout.EndScrollView(); } private void DrawStepTree(PuzzleStepSO step, int indent) { EditorGUILayout.BeginHorizontal(); GUILayout.Space(indent * INDENT_SIZE); EditorGUILayout.BeginVertical("box"); EditorGUILayout.LabelField($"{step.displayName} ({step.stepId})", EditorStyles.boldLabel); EditorGUILayout.LabelField(step.description ?? "", EditorStyles.wordWrappedLabel); GUILayout.Space(4); if (GUILayout.Button("Open in Inspector", GUILayout.Width(150))) { Selection.activeObject = step; // Opens in Inspector EditorGUIUtility.PingObject(step); // Highlights in Project } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); GUILayout.Space(6); // Spacer between steps foreach (var unlock in step.unlocks) { DrawStepTree(unlock, indent + 1); } } }