기존 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", false, 0)]
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 |
'Technical Art > 2022' 카테고리의 다른 글
| [Unity Editor Script] 텍스처 설정 일괄 변경 작업용 스크립트 (0) | 2022.08.06 |
|---|---|
| [Unity Editor Script] 이펙트 DecoPartsObject 구성을 쉽게하기 위한 내용 일부 수정 (0) | 2022.08.06 |
| [Unity Shader] UGUI addtive 적용위한 쉐이더 (0) | 2022.08.06 |