@@ -126,64 +126,7 @@ public void OnGUI()
126
126
EditorGUILayout . EndVertical ( ) ;
127
127
}
128
128
129
- EditorGUILayout . BeginHorizontal ( ) ;
130
-
131
- if ( GUILayout . Button ( "Reset" , GUILayout . Height ( 30 ) ) )
132
- {
133
- ResetFields ( ) ;
134
- }
135
129
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 ( ) ;
187
130
188
131
189
132
@@ -245,7 +188,64 @@ public void OnGUI()
245
188
246
189
247
190
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
+
248
206
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 ( ) ;
249
249
250
250
if ( LastPackingTime > 0 )
251
251
{
0 commit comments