Skip to content

Commit 8aec87d

Browse files
committed
edit texture packing window layout
1 parent 6226ac4 commit 8aec87d

File tree

1 file changed

+70
-24
lines changed

1 file changed

+70
-24
lines changed

Editor/TexturePacking/FreeImagePackingEditor.cs

Lines changed: 70 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,18 @@ public static void ResetFields()
6868
ChannelR.Channel.DefaultColor = DefaultColor.White;
6969
ChannelG.Channel.DefaultColor = DefaultColor.White;
7070
ChannelB.Channel.DefaultColor = DefaultColor.White;
71+
72+
packingSuffix = "";
7173
}
7274

7375
public static PackingField ChannelR;
7476
public static PackingField ChannelG;
7577
public static PackingField ChannelB;
7678
public static PackingField ChannelA;
7779

80+
public static string packingSuffix = "";
81+
82+
7883
public static Texture2D PackedTexture = null;
7984
private static Vector2Int _customSize = new Vector2Int(1024, 1024);
8085
public static bool Linear = false;
@@ -121,34 +126,14 @@ public void OnGUI()
121126
EditorGUILayout.EndVertical();
122127
}
123128

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-
145129
EditorGUILayout.BeginHorizontal();
146-
if (GUILayout.Button("Reset"))
130+
131+
if (GUILayout.Button("Reset", GUILayout.Height(30)))
147132
{
148133
ResetFields();
149134
}
150135

151-
if (GUILayout.Button("Pack"))
136+
if (GUILayout.Button("Pack", GUILayout.Height(30)))
152137
{
153138
GetTexturePath(ref ChannelR);
154139
GetTexturePath(ref ChannelG);
@@ -198,6 +183,66 @@ public void OnGUI()
198183
onPackingFinished.Invoke();
199184
}
200185
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+
201246

202247
EditorGUILayout.EndVertical();
203248

@@ -225,7 +270,8 @@ public static string GetPackedTexturePath(string referencePath)
225270
var directory = Path.GetDirectoryName(referencePath);
226271
var fileName = Path.GetFileNameWithoutExtension(referencePath);
227272

228-
var newPath = directory + @"\" + fileName + "_packed";
273+
var newPath = directory + @"\" + fileName +
274+
(string.IsNullOrEmpty(packingSuffix) ? "_packed" : packingSuffix);
229275
var extension = PackingFormat.GetExtension();
230276

231277
newPath = newPath + "." + extension;

0 commit comments

Comments
 (0)