public static bool ReplaceAnimation(this AnimatorOverrideController oc, int index, AnimationClip c) { var overrides = new List <KeyValuePair <AnimationClip, AnimationClip> >(); oc.GetOverrides(overrides); return(oc.ReplaceAnimation(overrides, index, c)); }
public static bool ReplaceAnimation(this AnimatorOverrideController oc, List <KeyValuePair <AnimationClip, AnimationClip> > overrides, string name, AnimationClip c) { for (int i = 0; i < overrides.Count; i++) { var current = overrides[i]; if (current.Key.name == name) { return(oc.ReplaceAnimation(overrides, i, c)); } } Debug.LogWarning($"Failed to find animation clip for name {name} to be replaced. Check spelling?"); return(false); }