Skip to content

Commit ed258a9

Browse files
committed
move packing button back to original position
1 parent 061053b commit ed258a9

File tree

1 file changed

+57
-57
lines changed

1 file changed

+57
-57
lines changed

Editor/TexturePacking/FreeImagePackingEditor.cs

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -126,64 +126,7 @@ public void OnGUI()
126126
EditorGUILayout.EndVertical();
127127
}
128128

129-
EditorGUILayout.BeginHorizontal();
130-
131-
if (GUILayout.Button("Reset", GUILayout.Height(30)))
132-
{
133-
ResetFields();
134-
}
135129

136-
if (GUILayout.Button("Pack", GUILayout.Height(30)))
137-
{
138-
GetTexturePath(ref ChannelR);
139-
GetTexturePath(ref ChannelG);
140-
GetTexturePath(ref ChannelB);
141-
GetTexturePath(ref ChannelA);
142-
143-
144-
var referenceTexture = ChannelG.UnityTexture ?? ChannelA.UnityTexture ?? ChannelR.UnityTexture ?? ChannelB.UnityTexture;
145-
if (referenceTexture == null) return;
146-
147-
var path = AssetDatabase.GetAssetPath(referenceTexture);
148-
var fullPath = Path.GetFullPath(path);
149-
150-
var absolutePath = GetPackedTexturePath(fullPath);
151-
var unityPath = GetPackedTexturePath(path);
152-
153-
int width = (int)Size;
154-
int height = (int)Size;
155-
156-
if (Size == TextureSize.Default)
157-
{
158-
width = referenceTexture.width;
159-
height = referenceTexture.height;
160-
}
161-
else if (Size == TextureSize.Custom)
162-
{
163-
width = _customSize.x;
164-
height = _customSize.y;
165-
}
166-
167-
PackCustom(absolutePath, ChannelR.Channel, ChannelG.Channel, ChannelB.Channel, ChannelA.Channel, (width, height), PackingFormat);
168-
169-
settingsNeedApply = true;
170-
AssetDatabase.ImportAsset(unityPath, ImportAssetOptions.ForceUpdate);
171-
172-
var texture = AssetDatabase.LoadAssetAtPath<Texture2D>(unityPath);
173-
174-
EditorGUIUtility.PingObject(texture);
175-
176-
if (_packingMaterial)
177-
{
178-
_packingMaterial.SetTexture(_packingPropertyName, texture);
179-
DefaultInspector.Reinitialize();
180-
MaterialEditor.ApplyMaterialPropertyDrawers(_packingMaterial);
181-
}
182-
183-
onPackingFinished.Invoke();
184-
}
185-
EditorGUILayout.EndHorizontal();
186-
EditorGUILayout.Space();
187130

188131

189132

@@ -245,7 +188,64 @@ public void OnGUI()
245188

246189

247190
EditorGUILayout.EndVertical();
191+
EditorGUILayout.Space();
192+
EditorGUILayout.BeginHorizontal();
193+
194+
if (GUILayout.Button("Reset", GUILayout.Height(30)))
195+
{
196+
ResetFields();
197+
}
198+
199+
if (GUILayout.Button("Pack", GUILayout.Height(30)))
200+
{
201+
GetTexturePath(ref ChannelR);
202+
GetTexturePath(ref ChannelG);
203+
GetTexturePath(ref ChannelB);
204+
GetTexturePath(ref ChannelA);
205+
248206

207+
var referenceTexture = ChannelG.UnityTexture ?? ChannelA.UnityTexture ?? ChannelR.UnityTexture ?? ChannelB.UnityTexture;
208+
if (referenceTexture == null) return;
209+
210+
var path = AssetDatabase.GetAssetPath(referenceTexture);
211+
var fullPath = Path.GetFullPath(path);
212+
213+
var absolutePath = GetPackedTexturePath(fullPath);
214+
var unityPath = GetPackedTexturePath(path);
215+
216+
int width = (int)Size;
217+
int height = (int)Size;
218+
219+
if (Size == TextureSize.Default)
220+
{
221+
width = referenceTexture.width;
222+
height = referenceTexture.height;
223+
}
224+
else if (Size == TextureSize.Custom)
225+
{
226+
width = _customSize.x;
227+
height = _customSize.y;
228+
}
229+
230+
PackCustom(absolutePath, ChannelR.Channel, ChannelG.Channel, ChannelB.Channel, ChannelA.Channel, (width, height), PackingFormat);
231+
232+
settingsNeedApply = true;
233+
AssetDatabase.ImportAsset(unityPath, ImportAssetOptions.ForceUpdate);
234+
235+
var texture = AssetDatabase.LoadAssetAtPath<Texture2D>(unityPath);
236+
237+
EditorGUIUtility.PingObject(texture);
238+
239+
if (_packingMaterial)
240+
{
241+
_packingMaterial.SetTexture(_packingPropertyName, texture);
242+
DefaultInspector.Reinitialize();
243+
MaterialEditor.ApplyMaterialPropertyDrawers(_packingMaterial);
244+
}
245+
246+
onPackingFinished.Invoke();
247+
}
248+
EditorGUILayout.EndHorizontal();
249249

250250
if (LastPackingTime > 0)
251251
{

0 commit comments

Comments
 (0)