기존 API 샘플 코드는 default animation clip만 추출할 수 있으나 이건 구성된 클립을 다 추출해 준다. 편안~
실행시 지정된 폴더에 추출할 수 있음 (코드 수정 필요)

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.IO;
using UnityEditor;
using UnityEngine;
 
public class AnimAssetDuplicator : MonoBehaviour
{
    [MenuItem("Assets/GameTools/Duplicate Animation Assets &d"false0)]
    public static void DuplicateAnimationAssetsInThisFolder()
    {
        foreach (var gameObject in Selection.gameObjects)
        {
            string path = AssetDatabase.GetAssetPath(gameObject);
            Object[] objects = AssetDatabase.LoadAllAssetsAtPath(path);
            foreach (Object obj in objects)
            {
                DuplicateAnimationClip(obj as AnimationClip);
            }
        }
    }
 
    private static void DuplicateAnimationClip(AnimationClip sourceClip)
    {
        if (sourceClip != null && !sourceClip.empty && !sourceClip.name.Contains("preview"))
        {
            string path = AssetDatabase.GetAssetPath(sourceClip);
            path = Path.Combine(Path.GetDirectoryName(path), sourceClip.name) + ".anim";
            // 중복인 경우 유니크한 파일레이블 설정
            //string newPath = AssetDatabase.GenerateUniqueAssetPath(path);
            // 복제할 경로 재설정 (기존 파일 오버라이트)
            string newPath = path.Replace("_Artworks""Prefabs");
            AnimationClip newClip = new AnimationClip();
            EditorUtility.CopySerialized(sourceClip, newClip);
            AssetDatabase.CreateAsset(newClip, newPath);
        }
    }
}
 
cs

AnimAssetDuplicator.cs
0.00MB

원본 출처 https://gist.github.com/BeautyfullCastle

+ Recent posts