Skip to main content

Get Current Project Window Directory

This is how you can get the current directory of the Project window:

using System.Reflection;
using UnityEditor;
using UnityEngine;

public static string GetActiveProjectWindowDirectory()
  	// Use Reflection to get the hidden method for getting the folder path
    MethodInfo getActiveFolderPathMethod = typeof(ProjectWindowUtil).GetMethod("GetActiveFolderPath", BindingFlags.Static | BindingFlags.NonPublic);

  	// Invoke the method to return the string
    return (string)getActiveFolderPathMethod.Invoke(null, null);