How to Get path from the current opened folder in the project window in unity editor
How to get path from both project windows menu? See image below
без-имени-1.jpg
(155.9 kB)
Comment
Answer by Danua · Aug 03, 2019 at 04:46 PM
using System;
using System.Reflection;
using UnityEngine;
using UnityEditor;
public class Test
{
[MenuItem("Assets/Ping")]
static void MyMethod()
{
Type projectWindowUtilType = typeof(ProjectWindowUtil);
MethodInfo getActiveFolderPath = projectWindowUtilType.GetMethod("GetActiveFolderPath", BindingFlags.Static | BindingFlags.NonPublic);
object obj = getActiveFolderPath.Invoke(null, new object[0]);
string pathToCurrentFolder = obj.ToString();
Debug.Log(pathToCurrentFolder);
}
}
That works
Your answer
Follow this Question
Related Questions
EditorWindow and serialization of scene objects 0 Answers
Problem with EditorGUILayout.ObjectField 1 Answer
I getting an error CS018 1 Answer
Linux Editor Issue scaling and elements disapearing 0 Answers