Created
July 16, 2014 15:53
-
-
Save noisecrime/5e928eedc003b91bbf80 to your computer and use it in GitHub Desktop.
Simple editor script to duplicate animation clips found in the selected model/animation asset file. Duplicates unlike original animation clips may be edited.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NoiseCrime Gist | |
// 2014.07.16 | |
// Unity Version: 3.5.7+ | |
// Simple editor script to duplicate animation clips found in the selected model/animation asset file. | |
// Duplicates unlike original animation clips may be edited. | |
using UnityEngine; | |
using UnityEditor; | |
public class Editor_DuplicateAnimationAsset : EditorWindow | |
{ | |
[MenuItem("Assets/Duplicate Animation Assets (NoiseCrime)")] | |
static void DoCreateAnimationAssets() | |
{ | |
if (Selection.activeGameObject.GetComponent<Animation>() != null) | |
{ | |
// Validate Folder Exists | |
if( !System.IO.Directory.Exists(Application.dataPath + "/DuplicatedAnimationClips")) | |
{ | |
AssetDatabase.CreateFolder("Assets", "DuplicatedAnimationClips"); | |
} | |
Animation anim = Selection.activeGameObject.GetComponent<Animation>(); | |
foreach (AnimationState sourceClip in anim) | |
{ | |
#if UNITY_4_3 | |
AnimationClip newClip = new AnimationClip(); | |
EditorUtility.CopySerialized(sourceClip.clip, newClip); | |
AssetDatabase.CreateAsset(newClip, string.Format("Assets/DuplicatedAnimationClips/{0}_dup.anim", sourceClip.name)); | |
#else | |
// Unity 3.5.7 | |
AssetDatabase.CreateAsset(sourceClip.clip, string.Format("Assets/DuplicatedAnimationClips/{0}_dup.anim", sourceClip.name)); | |
#endif | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment