概要
using System.Linq; using UnityEditor.Animations; public static class AnimatorControllerExt { public static bool HasNullMotion( this AnimatorController self ) { foreach ( var n in self.layers ) { if ( n.stateMachine.states.Any( c => c.state.motion == null ) ) { return true; } } return false; } }
using UnityEditor; using UnityEditor.Animations; using UnityEngine; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var path = AssetDatabase.GetAssetPath( Selection.activeObject ); var controller = AssetDatabase.LoadAssetAtPath<AnimatorController>( path ); Debug.Log( controller.HasNullMotion() ); } }
Animator Controller のいずれかのステートの Motion が
null になっている場合に true を返します