기존 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

텍스처 설정을 일괄적으로 수정할 수 있도록 작성한 스크립트

이펙트 텍스처 소스 - 밉맵 off / wrapmode clamp
모델링 텍스처 소스 - 밉맵 on / wrapmode repeat
ios / android 오버라이딩 checked
texture format ASTC 6x6 으로 변경

 

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
 
// /////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Batch Texture import settings modifier.
//
// Modifies all selected textures in the project window and applies the requested modification on the
// textures. Idea was to have the same choices for multiple files as you would have if you open the
// import settings of a single texture. Put this into Assets/Editor and once compiled by Unity you find
// the new functionality in Custom -> Texture. Enjoy! :-)
//
// Based on the great work of benblo in this thread:
// http://forum.unity3d.com/viewtopic.php?t=16079&start=0&postdays=0&postorder=asc&highlight=textureimporter
//
// Developed by Martin Schultz, Decane in August 2009
// e-mail: ms@decane.net
//
// /////////////////////////////////////////////////////////////////////////////////////////////////////////
public class ChangeTextureSettings : MonoBehaviour
{
 
    [MenuItem("Assets/GameTools/Change Texture Format/for Effect &t"false0)]
    static void ChangeTextureFormat_forEffect()
    {
#if UNITY_2018
        SelectedChangeTextureFormatSettings_forEffect(TextureImporterFormat.ASTC_RGBA_6x6);
#elif UNITY_2019 || UNITY_2020
        SelectedChangeTextureFormatSettings_forEffect(TextureImporterFormat.ASTC_6x6);
#endif
    }
 
    [MenuItem("Assets/GameTools/Change Texture Format/for Character"false0)]
    static void ChangeTextureFormat_forCharacter()
    {
#if UNITY_2018
        SelectedChangeTextureFormatSettings_forCharacter(TextureImporterFormat.ASTC_RGBA_6x6);
#elif UNITY_2019 || UNITY_2020
        SelectedChangeTextureFormatSettings_forCharacter(TextureImporterFormat.ASTC_6x6);
#endif
    }
 
    [MenuItem("Assets/GameTools/Change Texture Format/Auto"false20)]
    static void ChangeTextureFormat_Auto()
    {
        SelectedChangeTextureFormatSettings(TextureImporterFormat.Automatic);
    }
 
    [MenuItem("Assets/GameTools/Change Texture Format/ASTC_RGBA_6x6"false20)]
    static void ChangeTextureFormat_ASTC_RGBA_6x6()
    {
#if UNITY_2018
        SelectedChangeTextureFormatSettings(TextureImporterFormat.ASTC_RGBA_6x6);
#elif UNITY_2019 || UNITY_2020
        SelectedChangeTextureFormatSettings(TextureImporterFormat.ASTC_6x6);
#endif
    }
 
    // ----------------------------------------------------------------------------
 
    [MenuItem("Assets/GameTools/Change Max Size/512"false0)]
    static void ChangeTextureSize_512()
    {
        SelectedChangeMaxTextureSize(512);
    }
 
    [MenuItem("Assets/GameTools/Change Max Size/1024"false0)]
    static void ChangeTextureSize_1024()
    {
        SelectedChangeMaxTextureSize(1024);
    }
 
    [MenuItem("Assets/GameTools/Change Max Size/2048"false0)]
    static void ChangeTextureSize_2048()
    {
        SelectedChangeMaxTextureSize(2048);
    }
 
    // ----------------------------------------------------------------------------
 
    [MenuItem("Assets/GameTools/Change MipMap/Enable MipMap"false0)]
    static void ChangeMipMap_On()
    {
        SelectedChangeMimMap(true);
    }
 
    [MenuItem("Assets/GameTools/Change MipMap/Disable MipMap"false0)]
    static void ChangeMipMap_Off()
    {
        SelectedChangeMimMap(false);
    }
 
    // ----------------------------------------------------------------------------
 
    static void SelectedChangeMimMap(bool enabled)
    {
 
        Object[] textures = GetSelectedTextures();
        Selection.objects = new Object[0];
        foreach (Texture2D texture in textures)
        {
            string path = AssetDatabase.GetAssetPath(texture);
            Debug.Log("path: " + path);
            TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
            textureImporter.mipmapEnabled = enabled;
            AssetDatabase.ImportAsset(path);
        }
    }
 
    static void SelectedChangeMaxTextureSize(int size)
    {
 
        Object[] textures = GetSelectedTextures();
        Selection.objects = new Object[0];
        foreach (Texture2D texture in textures)
        {
            string path = AssetDatabase.GetAssetPath(texture);
            Debug.Log("path: " + path);
            TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
            textureImporter.maxTextureSize = size;
            AssetDatabase.ImportAsset(path);
        }
    }
 
    static void SelectedChangeTextureFormatSettings(TextureImporterFormat newFormat)
    {
 
        Object[] textures = GetSelectedTextures();
        Selection.objects = new Object[0];
        foreach (Texture2D texture in textures)
        {
            string path = AssetDatabase.GetAssetPath(texture);
            Debug.Log("path: " + path);
            TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
            //textureImporter.textureFormat = newFormat;
            //AssetDatabase.ImportAsset(path);
 
            // 플랫폼별 텍스처 포맷 설정
            TextureImporterPlatformSettings settingPlatform = textureImporter.GetPlatformTextureSettings("iPhone");
            settingPlatform.format = newFormat;
            settingPlatform.overridden = true;
            textureImporter.SetPlatformTextureSettings(settingPlatform);
 
            settingPlatform = textureImporter.GetPlatformTextureSettings("Android");
            settingPlatform.format = newFormat;
            settingPlatform.overridden = true;
            textureImporter.SetPlatformTextureSettings(settingPlatform);
            //textureImporter.SaveAndReimport();
 
            AssetDatabase.ImportAsset(path);
        }
        Debug.Log("텍스처 포맷 변환 완료!");
    }
 
    static void SelectedChangeTextureFormatSettings_forEffect(TextureImporterFormat newFormat)
    {
 
        Object[] textures = GetSelectedTextures();
        Selection.objects = new Object[0];
        foreach (Texture2D texture in textures)
        {
            string path = AssetDatabase.GetAssetPath(texture);
            Debug.Log("path: " + path);
            TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
            //textureImporter.textureFormat = newFormat;
            //AssetDatabase.ImportAsset(path);
 
            // 플랫폼별 텍스처 포맷 설정
            TextureImporterPlatformSettings settingPlatform = textureImporter.GetPlatformTextureSettings("iPhone");
            settingPlatform.format = newFormat;
            settingPlatform.overridden = true;
            textureImporter.SetPlatformTextureSettings(settingPlatform);
 
            settingPlatform = textureImporter.GetPlatformTextureSettings("Android");
            settingPlatform.format = newFormat;
            settingPlatform.overridden = true;
            textureImporter.SetPlatformTextureSettings(settingPlatform);
 
            textureImporter.mipmapEnabled = false// 이펙트용
            textureImporter.wrapMode = TextureWrapMode.Clamp;
            //textureImporter.SaveAndReimport();
 
            AssetDatabase.ImportAsset(path);
        }
        Debug.Log("텍스처 포맷 변환 완료!");
    }
    static void SelectedChangeTextureFormatSettings_forCharacter(TextureImporterFormat newFormat)
    {
 
        Object[] textures = GetSelectedTextures();
        Selection.objects = new Object[0];
        foreach (Texture2D texture in textures)
        {
            string path = AssetDatabase.GetAssetPath(texture);
            Debug.Log("path: " + path);
            TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
            //textureImporter.textureFormat = newFormat;
            //AssetDatabase.ImportAsset(path);
 
            // 플랫폼별 텍스처 포맷 설정
            TextureImporterPlatformSettings settingPlatform = textureImporter.GetPlatformTextureSettings("iPhone");
            settingPlatform.format = newFormat;
            settingPlatform.overridden = true;
            textureImporter.SetPlatformTextureSettings(settingPlatform);
 
            settingPlatform = textureImporter.GetPlatformTextureSettings("Android");
            settingPlatform.format = newFormat;
            settingPlatform.overridden = true;
            textureImporter.SetPlatformTextureSettings(settingPlatform);
 
            textureImporter.mipmapEnabled = true// 캐릭터용
            textureImporter.wrapMode = TextureWrapMode.Repeat;
            //textureImporter.SaveAndReimport();
 
            AssetDatabase.ImportAsset(path);
        }
        Debug.Log("텍스처 포맷 변환 완료!");
    }
 
    static Object[] GetSelectedTextures()
    {
        return Selection.GetFiltered(typeof(Texture2D), SelectionMode.DeepAssets);
    }
}
 
cs

ChangeTextureSettings.cs
0.01MB

캐릭터 매쉬 프리팹에 이펙트 어테치를 하기 위한 노드 추가 작업시 기본값을 구성하여 클릭만으로 편하게 사용하기 위해 일부 내용 추가

 

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
// ...
 
        void DrawDecoObjectList()
        {
            EditorGUILayout.BeginHorizontal();
            _isFoldoutDecoObjectList = EditorGUILayout.Toggle(_isFoldoutDecoObjectList, EditorStyles.foldout, GUILayout.Width(10));
            EditorGUILayout.LabelField("[PartsDecoEditor]", EditorStyles.boldLabel);
 
            if (GUILayout.Button("DecoObject 추가"))
            {
                PartsDecoInfo newDummyObject = new PartsDecoInfo()
                {
                    DirectionType = PartsDecoDirectionType.Default,
                    ParentBoneName = "Bip001 Pelvis",
                    DecoObject = null,
                };
 
                // 파츠 DecoObject 좌표 기본값
                Vector3 decoLocalPosition = Vector3.zero;
                Quaternion decoLocalRotation = Quaternion.identity;
 
                // 해당 문자열 포함여부로 파츠 및 성별 구분
                if (_fbxPartsObject.ToString().Contains("B_F_"))
                {
                    Debug.Log("가방_여성");
                    decoLocalPosition = new Vector3(0.025f, 0.184f, 0.128f);
                    decoLocalRotation = Quaternion.Euler(60180270);
                }
                else if (_fbxPartsObject.ToString().Contains("B_M_"))
                {
                    Debug.Log("가방_남성");
                    decoLocalPosition = new Vector3(-0.04f, 0.202f, 0.115f);
                    decoLocalRotation = Quaternion.Euler(60180270);
                }
                else if (_fbxPartsObject.ToString().Contains("R_F_"))
                {
                    Debug.Log("귀걸이_여성");
                    newDummyObject.ParentBoneName = "Bip001 Head";
                    decoLocalPosition = new Vector3(-0.036f, 0.045f, 0);
                    decoLocalRotation = Quaternion.Euler(270900);
                }
                else if (_fbxPartsObject.ToString().Contains("R_M_"))
                {
                    Debug.Log("귀걸이_남성");
                    newDummyObject.ParentBoneName = "Bip001 Head";
                    decoLocalPosition = new Vector3(-0.036f, 0.045f, 0);
                    decoLocalRotation = Quaternion.Euler(270900);
                }
                else if (_fbxPartsObject.ToString().Contains("F_F_"))
                {
                    Debug.Log("얼굴_여성");
                    newDummyObject.ParentBoneName = "Bip001 Head";
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("F_M_"))
                {
                    Debug.Log("얼굴_남성");
                    newDummyObject.ParentBoneName = "Bip001 Head";
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("U_F_"))
                {
                    Debug.Log("얼굴악세_여성");
                    newDummyObject.ParentBoneName = "Bip001 Head";
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("U_M_"))
                {
                    Debug.Log("얼굴악세_남성");
                    newDummyObject.ParentBoneName = "Bip001 Head";
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("H_F_"))
                {
                    Debug.Log("헤어_여성");
                    newDummyObject.ParentBoneName = "Bip001 Head";
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("H_M_"))
                {
                    Debug.Log("헤어_남성");
                    newDummyObject.ParentBoneName = "Bip001 Head";
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("I_F_"))
                {
                    Debug.Log("헤어악세_여성");
                    newDummyObject.ParentBoneName = "Bip001 Head";
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("I_M_"))
                {
                    Debug.Log("헤어악세_남성");
                    newDummyObject.ParentBoneName = "Bip001 Head";
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("A_F_"))
                {
                    if (_instancePartsDataInfo.DecoList.Count % 2 == 0)
                    {
                        Debug.Log("핸드_여성_오른손");
                        newDummyObject.ParentBoneName = "Bip001 R Hand";
                        newDummyObject.DirectionType = PartsDecoDirectionType.Right;
                    }
                    else
                    {
                        Debug.Log("핸드_여성_왼손");
                        newDummyObject.ParentBoneName = "Bip001 L Hand";
                        newDummyObject.DirectionType = PartsDecoDirectionType.Left;
                    }
                    decoLocalPosition = new Vector3(-0.123f, -0.015f, 0);
                    decoLocalRotation = Quaternion.Euler(00270);
                }
                else if (_fbxPartsObject.ToString().Contains("A_M_"))
                {
                    if (_instancePartsDataInfo.DecoList.Count % 2 == 0)
                    {
                        Debug.Log("핸드_남성_오른손");
                        newDummyObject.ParentBoneName = "Bip001 R Hand";
                        newDummyObject.DirectionType = PartsDecoDirectionType.Right;
                    }
                    else
                    {
                        Debug.Log("핸드_남성_왼손");
                        newDummyObject.ParentBoneName = "Bip001 L Hand";
                        newDummyObject.DirectionType = PartsDecoDirectionType.Left;
                    }
                    decoLocalPosition = new Vector3(-0.117f, -0.037f, 0);
                    decoLocalRotation = Quaternion.Euler(00270);
                }
                else if (_fbxPartsObject.ToString().Contains("J_F_"))
                {
                    Debug.Log("자켓_여성");
                    decoLocalPosition = new Vector3(0.9f, 00);
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("J_M_"))
                {
                    Debug.Log("자켓_남성");
                    decoLocalPosition = new Vector3(0.9f, 00);
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("K_F_"))
                {
                    Debug.Log("목걸이_여성");
                    newDummyObject.ParentBoneName = "Bip001 Neck";
                    decoLocalPosition = new Vector3(0.05f, 0.16f, 0);
                    decoLocalRotation = Quaternion.Euler(7090180);
                }
                else if (_fbxPartsObject.ToString().Contains("K_M_"))
                {
                    Debug.Log("목걸이_남성");
                    newDummyObject.ParentBoneName = "Bip001 Neck";
                    decoLocalPosition = new Vector3(0.05f, 0.16f, 0);
                    decoLocalRotation = Quaternion.Euler(7090180);
                }
                else if (_fbxPartsObject.ToString().Contains("P_F_"))
                {
                    Debug.Log("팬츠_여성");
                    decoLocalPosition = new Vector3(0.9f, 00);
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("P_M_"))
                {
                    Debug.Log("팬츠_남성");
                    decoLocalPosition = new Vector3(0.9f, 00);
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("T_F_"))
                {
                    Debug.Log("세트_여성");
                    decoLocalPosition = new Vector3(0.9f, 00);
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("T_M_"))
                {
                    Debug.Log("세트_남성");
                    decoLocalPosition = new Vector3(0.9f, 00);
                    decoLocalRotation = Quaternion.Euler(902700);
                }
                else if (_fbxPartsObject.ToString().Contains("S_F_"))
                {
                    if (_instancePartsDataInfo.DecoList.Count % 2 == 0)
                    {
                        Debug.Log("신발_여성_오른발");
                        newDummyObject.ParentBoneName = "Bip001 R Foot";
                        newDummyObject.DirectionType = PartsDecoDirectionType.Right;
                    }
                    else
                    {
                        Debug.Log("신발_여성_왼발");
                        newDummyObject.ParentBoneName = "Bip001 L Foot";
                        newDummyObject.DirectionType = PartsDecoDirectionType.Left;
                    }
                    decoLocalPosition = new Vector3(-0.136f, 0.114f, -0.004f);
                    decoLocalRotation = Quaternion.Euler(90900);
                }
                else if (_fbxPartsObject.ToString().Contains("S_M_"))
                {
                    if (_instancePartsDataInfo.DecoList.Count % 2 == 0)
                    {
                        Debug.Log("신발_남성_오른발");
                        newDummyObject.ParentBoneName = "Bip001 R Foot";
                        newDummyObject.DirectionType = PartsDecoDirectionType.Right;
                    }
                    else
                    {
                        Debug.Log("신발_남성_왼발");
                        newDummyObject.ParentBoneName = "Bip001 L Foot";
                        newDummyObject.DirectionType = PartsDecoDirectionType.Left;
                    }
                    decoLocalPosition = new Vector3(-0.136f, 0.114f, -0.004f);
                    decoLocalRotation = Quaternion.Euler(90900);
                }
 
                var decoGameObject = new GameObject("DecoParentObject");
                decoGameObject.transform.localPosition = decoLocalPosition;
                decoGameObject.transform.localRotation = decoLocalRotation;
                decoGameObject.transform.localScale = Vector3.one;
                decoGameObject.transform.SetParent(_instancePartsDataInfo.transform, false);
 
                newDummyObject.DecoParentTransform = decoGameObject.transform;
 
                _instancePartsDataInfo.DecoList.Add(newDummyObject);
            }
 
            EditorGUILayout.EndHorizontal();
 
// 이하 생략...
cs

 

[첨부파일] 비공개

+ Recent posts