public static UnityEditor.Animations.AnimatorState RemoveStateWith(this UnityEditor.Animations.AnimatorController controller, int nameHash, int layerIndex = 0) { UnityEditor.Animations.AnimatorState state = controller.GetStateBy(nameHash, layerIndex); if (state != null) { controller.layers [layerIndex].stateMachine.RemoveState(state); return(state); } return(null); }