// =============================================================================== // ProjectNavigation - Navigation History for Unity Project Window // // Creator: Scove // Last Updated: 2026-03-05 // Version: 1.1 // // Purpose: // This tool provides a navigation history for the Unity Project window, allowing // users to quickly jump back and forward between previously visited folders. // // Key Features: // 1. Tracks folder selection history automatically. // 2. Supports Back and Forward navigation via menu items and shortcuts. // 3. Pings the selected folder for quick visual identification. // // How to Use: // 1. Place this script in an 'Editor' folder in your project. // 2. Use Alt + Left Arrow to navigate Back. // 3. Use Alt + Right Arrow to navigate Forward. // =============================================================================== using System.Collections.Generic; using UnityEditor; using UnityEngine; namespace Editor { public class ProjectNavigation : EditorWindow { private static List history = new List(); private static int currentIndex = -1; private static string lastPath = ""; // Store the current position when selecting a folder [InitializeOnLoadMethod] static void Init() { Selection.selectionChanged += OnSelectionChanged; } static void OnSelectionChanged() { if (Selection.activeObject != null) { string path = AssetDatabase.GetAssetPath(Selection.activeObject); // Only track if it's a valid folder and different from the last recorded path if (AssetDatabase.IsValidFolder(path) && path != lastPath) { // If we are in the middle of history and perform a new "direct jump", // clear the forward history (browser-style navigation) if (currentIndex < history.Count - 1) { history.RemoveRange(currentIndex + 1, history.Count - (currentIndex + 1)); } history.Add(path); currentIndex++; lastPath = path; } } } // Shortcut Alt + Left Arrow (Back) [MenuItem("Tools/Navigation/Back &LEFT")] static void Back() { if (currentIndex > 0) { currentIndex--; NavigateTo(history[currentIndex]); } } // Shortcut Alt + Right Arrow (Forward) [MenuItem("Tools/Navigation/Forward &RIGHT")] static void Forward() { if (currentIndex < history.Count - 1) { currentIndex++; NavigateTo(history[currentIndex]); } } static void NavigateTo(string path) { lastPath = path; Object obj = AssetDatabase.LoadAssetAtPath(path); Selection.activeObject = obj; EditorGUIUtility.PingObject(obj); } } }