@@ -68,13 +68,18 @@ public static void ResetFields()
68
68
ChannelR . Channel . DefaultColor = DefaultColor . White ;
69
69
ChannelG . Channel . DefaultColor = DefaultColor . White ;
70
70
ChannelB . Channel . DefaultColor = DefaultColor . White ;
71
+
72
+ packingSuffix = "" ;
71
73
}
72
74
73
75
public static PackingField ChannelR ;
74
76
public static PackingField ChannelG ;
75
77
public static PackingField ChannelB ;
76
78
public static PackingField ChannelA ;
77
79
80
+ public static string packingSuffix = "" ;
81
+
82
+
78
83
public static Texture2D PackedTexture = null ;
79
84
private static Vector2Int _customSize = new Vector2Int ( 1024 , 1024 ) ;
80
85
public static bool Linear = false ;
@@ -121,34 +126,14 @@ public void OnGUI()
121
126
EditorGUILayout . EndVertical ( ) ;
122
127
}
123
128
124
-
125
- TexturePackingField ( ref ChannelR , Color . red , _preview0 , _firstTime ) ;
126
- TexturePackingField ( ref ChannelG , Color . green , _preview1 , _firstTime ) ;
127
- TexturePackingField ( ref ChannelB , Color . blue , _preview2 , _firstTime ) ;
128
- TexturePackingField ( ref ChannelA , Color . white , _preview3 , _firstTime ) ;
129
- _firstTime = false ;
130
-
131
-
132
- EditorGUILayout . BeginVertical ( _guiStyle ) ;
133
- PackingFormat = ( TexturePackingFormat ) EditorGUILayout . EnumPopup ( "Format" , PackingFormat ) ;
134
- ImageFilter = ( FreeImage . FREE_IMAGE_FILTER ) EditorGUILayout . EnumPopup ( new GUIContent ( "Rescale Filter" , "Filter that will be used for rescaling textures to match them to the target size if needed" ) , ImageFilter ) ;
135
- Size = ( TextureSize ) EditorGUILayout . EnumPopup ( new GUIContent ( "Size" , "Specify the size of the packed texture" ) , Size ) ;
136
- if ( Size == TextureSize . Custom )
137
- {
138
- EditorGUI . indentLevel ++ ;
139
- _customSize = EditorGUILayout . Vector2IntField ( new GUIContent ( ) , _customSize ) ;
140
- EditorGUI . indentLevel -- ;
141
- }
142
- //Linear = EditorGUILayout.Toggle(new GUIContent("Linear", "Disable sRGB on texture import, for mask and data textures (Roughness, Occlusion, Metallic etc)"), Linear);
143
-
144
-
145
129
EditorGUILayout . BeginHorizontal ( ) ;
146
- if ( GUILayout . Button ( "Reset" ) )
130
+
131
+ if ( GUILayout . Button ( "Reset" , GUILayout . Height ( 30 ) ) )
147
132
{
148
133
ResetFields ( ) ;
149
134
}
150
135
151
- if ( GUILayout . Button ( "Pack" ) )
136
+ if ( GUILayout . Button ( "Pack" , GUILayout . Height ( 30 ) ) )
152
137
{
153
138
GetTexturePath ( ref ChannelR ) ;
154
139
GetTexturePath ( ref ChannelG ) ;
@@ -198,6 +183,66 @@ public void OnGUI()
198
183
onPackingFinished . Invoke ( ) ;
199
184
}
200
185
EditorGUILayout . EndHorizontal ( ) ;
186
+ EditorGUILayout . Space ( ) ;
187
+
188
+
189
+
190
+
191
+
192
+ TexturePackingField ( ref ChannelR , Color . red , _preview0 , _firstTime ) ;
193
+ TexturePackingField ( ref ChannelG , Color . green , _preview1 , _firstTime ) ;
194
+ TexturePackingField ( ref ChannelB , Color . blue , _preview2 , _firstTime ) ;
195
+ TexturePackingField ( ref ChannelA , Color . white , _preview3 , _firstTime ) ;
196
+ _firstTime = false ;
197
+
198
+ EditorGUILayout . Space ( ) ;
199
+ EditorGUILayout . BeginVertical ( _guiStyle ) ;
200
+
201
+ EditorGUILayout . BeginHorizontal ( ) ;
202
+ EditorGUILayout . LabelField ( "Preset" , GUILayout . Width ( 149 ) ) ;
203
+ if ( GUILayout . Button ( "Mask Map" ) )
204
+ {
205
+ ChannelR . Channel . DefaultColor = DefaultColor . White ;
206
+ ChannelG . Channel . DefaultColor = DefaultColor . White ;
207
+ ChannelB . Channel . DefaultColor = DefaultColor . Black ;
208
+ ChannelA . Channel . DefaultColor = DefaultColor . White ;
209
+
210
+ ChannelR . DisplayName = "Ambient Occlusion" ;
211
+ ChannelG . DisplayName = "Roughness" ;
212
+ ChannelG . InvertDisplayName = "Smoothness" ;
213
+ ChannelB . DisplayName = "Metallic" ;
214
+ ChannelA . DisplayName = "Detail Mask" ;
215
+ packingSuffix = "_MaskMap" ;
216
+ }
217
+ if ( GUILayout . Button ( "Metallic Smoothness" ) )
218
+ {
219
+ ChannelR . Channel . DefaultColor = DefaultColor . Black ;
220
+ ChannelG . Channel . DefaultColor = DefaultColor . Black ;
221
+ ChannelB . Channel . DefaultColor = DefaultColor . Black ;
222
+ ChannelA . Channel . DefaultColor = DefaultColor . White ;
223
+
224
+ ChannelR . DisplayName = "Metallic" ;
225
+ ChannelA . DisplayName = "Smoothness" ;
226
+ ChannelA . InvertDisplayName = "Roughness" ;
227
+ ChannelB . DisplayName = "" ;
228
+ ChannelG . DisplayName = "" ;
229
+ packingSuffix = "_MetallicSmoothness" ;
230
+ }
231
+ EditorGUILayout . EndHorizontal ( ) ;
232
+
233
+ PackingFormat = ( TexturePackingFormat ) EditorGUILayout . EnumPopup ( "Format" , PackingFormat ) ;
234
+ ImageFilter = ( FreeImage . FREE_IMAGE_FILTER ) EditorGUILayout . EnumPopup ( new GUIContent ( "Rescale Filter" , "Filter that will be used for rescaling textures to match them to the target size if needed" ) , ImageFilter ) ;
235
+ Size = ( TextureSize ) EditorGUILayout . EnumPopup ( new GUIContent ( "Size" , "Specify the size of the packed texture" ) , Size ) ;
236
+ if ( Size == TextureSize . Custom )
237
+ {
238
+ EditorGUI . indentLevel ++ ;
239
+ _customSize = EditorGUILayout . Vector2IntField ( new GUIContent ( ) , _customSize ) ;
240
+ EditorGUI . indentLevel -- ;
241
+ }
242
+ //Linear = EditorGUILayout.Toggle(new GUIContent("Linear", "Disable sRGB on texture import, for mask and data textures (Roughness, Occlusion, Metallic etc)"), Linear);
243
+
244
+ packingSuffix = EditorGUILayout . TextField ( new GUIContent ( "Suffix" ) , packingSuffix ) ;
245
+
201
246
202
247
EditorGUILayout . EndVertical ( ) ;
203
248
@@ -225,7 +270,8 @@ public static string GetPackedTexturePath(string referencePath)
225
270
var directory = Path . GetDirectoryName ( referencePath ) ;
226
271
var fileName = Path . GetFileNameWithoutExtension ( referencePath ) ;
227
272
228
- var newPath = directory + @"\" + fileName + "_packed" ;
273
+ var newPath = directory + @"\" + fileName +
274
+ ( string . IsNullOrEmpty ( packingSuffix ) ? "_packed" : packingSuffix ) ;
229
275
var extension = PackingFormat . GetExtension ( ) ;
230
276
231
277
newPath = newPath + "." + extension ;
0 commit comments