You need to use **AssetDatabase.GetAssetPath()** and **Directory.Exists()** which is part of the **System.IO** library in C#.
At the top of your script include the **System.IO** library:
using System.IO;
Then check your selections with the following:
foreach (Object obj in Selection.objects) {
string selectionPath = AssetDatabase.GetAssetPath(obj); // relative path
if (Directory.Exists(selectionPath)) {
// do something
}
}
Note that **selectionPath** is a relative path but **Directory.Exists()** is smart enough to realize this and still use it.
↧