/// <summary>
		/// Adds convenience methods to determine the current Animator state as boolean methods to the class code 
		/// element (e.g. IsIdle ()). NOTE that this method relies on classes from namespace UnityEditorInternal 
		/// which can be subject to changes in future releases.
		/// </summary>
		public static void ProcessAllAnimatorStates (Animator animator, ProcessAnimatorState callback) {
			AnimatorController controller = GetInternalAnimatorController (animator);
			int layerCount = controller.layerCount;
			for (int layer = 0; layer < layerCount; layer++) {
				string layerName = controller.GetLayer (layer).name;
				UnityEditorInternal.StateMachine sm = controller.GetLayer (layer).stateMachine;
				for (int i = 0; i < sm.stateCount; i++) {
					UnityEditorInternal.State state = sm.GetState (i);
					Motion motion = state.GetMotion ();
					float duration = (motion != null ? motion.averageDuration : 0f);
					string motionName = (motion != null ? motion.name : "");
					StateInfo info = new StateInfo (state.uniqueNameHash, layer, layerName, state.uniqueName, state.tag,
						state.speed, state.iKOnFeet, state.mirror, motionName, duration);
					callback (info);
				}
			}
		}
示例#2
0
        /// <summary>
        /// Adds convenience methods to determine the current Animator state as boolean methods to the class code
        /// element (e.g. IsIdle ()). NOTE that this method relies on classes from namespace UnityEditorInternal
        /// which can be subject to changes in future releases.
        /// </summary>
        public static void ProcessAllAnimatorStates(Animator animator, ProcessAnimatorState callback)
        {
            AnimatorController controller = GetInternalAnimatorController(animator);
            int layerCount = controller.layerCount;

            for (int layer = 0; layer < layerCount; layer++)
            {
                string layerName = controller.GetLayer(layer).name;
                UnityEditorInternal.StateMachine sm = controller.GetLayer(layer).stateMachine;
                for (int i = 0; i < sm.stateCount; i++)
                {
                    UnityEditorInternal.State state = sm.GetState(i);
                    Motion    motion     = state.GetMotion();
                    float     duration   = (motion != null ? motion.averageDuration : 0f);
                    string    motionName = (motion != null ? motion.name : "");
                    StateInfo info       = new StateInfo(state.uniqueNameHash, layer, layerName, state.uniqueName, state.tag,
                                                         state.speed, state.iKOnFeet, state.mirror, motionName, duration);
                    callback(info);
                }
            }
        }