The problem with your question is it's really hard to define "which plugins may not be used"...
Simply because a plugin may be referenced in a script means the plugin may be used? Or does the script need to be referenced as well somewhere else?
I mean: let's take the example of a plugin being referenced in a non-MonoBehaviour class that is itself referenced in another MonoBehaviour class. You may not be using the MonoBehaviour class nor the non-MonoBehaviour one: but if you delete the plugin, you will have to either delete the two classes or adapt them (using scripting define symbols maybe).
A quick example of something that could be used would be this:
List<string> pluginsNotUsed = new List<string>();
UnityEditor.PluginImporter[] importers = UnityEditor.PluginImporter.GetAllImporters();
for(int i = 0; i < importers.Length; i++)
{
if(!pluginsNotUsed.Contains(importers[i].assetPath))
{
pluginsNotUsed.Add(importers[i].assetPath);
}
}
// ---- This part removes the plugins that match the current targeted build platform
importers = UnityEditor.PluginImporter.GetImporters(UnityEditor.EditorUserBuildSettings.activeBuildTarget);
for(int i = 0; i < importers.Length; i++)
{
if(pluginsNotUsed.Contains(importers[i].assetPath))
{
pluginsNotUsed.Remove(importers[i].assetPath);
}
}
// ----
Object obj = null;
for(int i = 0; i < pluginsNotUsed.Count; i++)
{
// Remove this condition if you want to display all the loaded plugins
// (including the ones installed withy Unity: C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/...)
if(pluginsNotUsed[i].StartsWith("Assets/"))
{
obj = UnityEditor.AssetDatabase.LoadAssetAtPath(pluginsNotUsed[i], UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(pluginsNotUsed[i]));
Debug.Log(pluginsNotUsed[i], obj);
}
}
This piece of script will list you all the loaded plugins that are not set to support your current targeted build platform (and that therefore should not be used).
In addition to that you could go further and check for all the loaded plugins that match your current targeted build platform (remove the middle part and use GetImporters(UnityEditor.EditorUserBuildSettings.activeBuildTarget);
) and then use some kind of parsing to check in your current solution for references to the found plugins.
Keep in mind what I suggested last will be hard to automate: not even sure there is a way to retrieve all the methods exposed in a plugin in order to check for them in your files. Furthermore you will have to check if the class in which you found such references are used in one of your project scenes or prefabs if you want to be sure you can delete it safely.
Well sorry for the wall of text, also I know I didn't really answered your question but I hope I gave you the right direction :)
Hope this helps,