public static void FillInClips() { string directory = SelectionUtility.GetDirectoryOfSelection(); // Get all animation clips in the current directory List <AnimationClip> clipsForAnimator = new List <AnimationClip>(); string[] clipGUIDs = AssetDatabase.FindAssets("t:animationClip"); directory = directory.Replace(@"\", @"/"); foreach (string clipGUID in clipGUIDs) { string guidPath = AssetDatabase.GUIDToAssetPath(clipGUID); Debug.Log($"guidPath: {guidPath}"); Debug.Log($"directory: {directory}"); if (guidPath.Contains(directory)) { Debug.Log($"directory: {directory}"); clipsForAnimator.Add(AssetDatabase.LoadAssetAtPath <AnimationClip>(guidPath)); } } AnimatorOverrideController overrideController = (AnimatorOverrideController)Selection.activeObject; Debug.Log($"clip: {clipsForAnimator.Count}"); // Replace clips if they match foreach (AnimationClip clip in clipsForAnimator) { Debug.Log($"clip: {clip}"); Debug.Log("test"); // Get just the clip name string clipAnimName = ExtractAnimNameFromClipName(clip.name); Debug.Log("Searching for matches for clip: " + clipAnimName); // Find the corresponding clip to replace for (int i = 0; i < overrideController.clips.Length; i++) { string originalClipName = overrideController.clips[i].originalClip.name; string animName = ExtractAnimNameFromClipName(originalClipName); if (clipAnimName == animName) { Debug.Log("Replacing clip: " + originalClipName + " With: " + clip.name); overrideController[originalClipName] = clip; break; } } } }
private static bool IsFillInClipsValid() { return(SelectionUtility.IsActiveObjectOfType <AnimatorOverrideController>()); }