After double clicking on an animation controller asset the animator window will open and allow you to inspect the controller. Is there a way to find out what the controller that is active in that window is?
I noticed you can get the state that is selected in that window through Selection.activeObject but I can’t find a path back to the controller from there.
Necro, in case anyone else comes looking for an answer. Reflection isn’t needed. You can access the source-controller using the AssetDatabase, since States are part of the Controller asset.
AnimatorState state; // via Selection.activeObject, or MenuCommand.context
string controllerAssetPath = AssetDatabase.GetAssetPath (state);
AnimatorController animController =
AssetDatabase.LoadAssetAtPath<AnimatorController> (controllerAssetPath);