텍스처 설정을 일괄적으로 수정할 수 있도록 작성한 스크립트
이펙트 텍스처 소스 - 밉맵 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", false, 0)]
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", false, 0)]
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", false, 20)]
static void ChangeTextureFormat_Auto()
{
SelectedChangeTextureFormatSettings(TextureImporterFormat.Automatic);
}
[MenuItem("Assets/GameTools/Change Texture Format/ASTC_RGBA_6x6", false, 20)]
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", false, 0)]
static void ChangeTextureSize_512()
{
SelectedChangeMaxTextureSize(512);
}
[MenuItem("Assets/GameTools/Change Max Size/1024", false, 0)]
static void ChangeTextureSize_1024()
{
SelectedChangeMaxTextureSize(1024);
}
[MenuItem("Assets/GameTools/Change Max Size/2048", false, 0)]
static void ChangeTextureSize_2048()
{
SelectedChangeMaxTextureSize(2048);
}
// ----------------------------------------------------------------------------
[MenuItem("Assets/GameTools/Change MipMap/Enable MipMap", false, 0)]
static void ChangeMipMap_On()
{
SelectedChangeMimMap(true);
}
[MenuItem("Assets/GameTools/Change MipMap/Disable MipMap", false, 0)]
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 |
'Technical Art > 2022' 카테고리의 다른 글
[Unity Editor Script] fbx에서 애니메이션 클립을 쉽게 추출하도록 일부 내용 수정한 스크립트 (0) | 2022.08.06 |
---|---|
[Unity Editor Script] 이펙트 DecoPartsObject 구성을 쉽게하기 위한 내용 일부 수정 (0) | 2022.08.06 |
[Unity Shader] UGUI addtive 적용위한 쉐이더 (0) | 2022.08.06 |