@@ -97,14 +97,8 @@ public Styles()
9797
9898 private static Styles s_Styles ;
9999
100- private readonly string kDefaultPlatformName = "default" ;
101-
102100 private enum AtlasType { Undefined = - 1 , Master = 0 , Variant = 1 }
103101
104- private SerializedProperty m_MaxTextureSize ;
105- private SerializedProperty m_TextureCompression ;
106- private SerializedProperty m_UseCrunchedCompression ;
107- private SerializedProperty m_CompressionQuality ;
108102 private SerializedProperty m_FilterMode ;
109103 private SerializedProperty m_AnisoLevel ;
110104 private SerializedProperty m_GenerateMipMaps ;
@@ -117,7 +111,7 @@ private enum AtlasType { Undefined = -1, Master = 0, Variant = 1 }
117111 private SerializedProperty m_Packables ;
118112
119113 private SerializedProperty m_MasterAtlas ;
120- private SerializedProperty m_VariantMultiplier ;
114+ private SerializedProperty m_VariantScale ;
121115
122116 private string m_Hash ;
123117 private int m_PreviewPage = 0 ;
@@ -176,23 +170,19 @@ bool AllTargetsAreMaster()
176170
177171 void OnEnable ( )
178172 {
179- m_MaxTextureSize = serializedObject . FindProperty ( "m_EditorData.textureSettings.maxTextureSize" ) ;
180- m_TextureCompression = serializedObject . FindProperty ( "m_EditorData.textureSettings.textureCompression" ) ;
181- m_UseCrunchedCompression = serializedObject . FindProperty ( "m_EditorData.textureSettings.crunchedCompression" ) ;
182- m_CompressionQuality = serializedObject . FindProperty ( "m_EditorData.textureSettings.compressionQuality" ) ;
183173 m_FilterMode = serializedObject . FindProperty ( "m_EditorData.textureSettings.filterMode" ) ;
184174 m_AnisoLevel = serializedObject . FindProperty ( "m_EditorData.textureSettings.anisoLevel" ) ;
185175 m_GenerateMipMaps = serializedObject . FindProperty ( "m_EditorData.textureSettings.generateMipMaps" ) ;
186176 m_Readable = serializedObject . FindProperty ( "m_EditorData.textureSettings.readable" ) ;
187177 m_UseSRGB = serializedObject . FindProperty ( "m_EditorData.textureSettings.sRGB" ) ;
188178
189- m_EnableTightPacking = serializedObject . FindProperty ( "m_EditorData.packingParameters .enableTightPacking" ) ;
190- m_EnableRotation = serializedObject . FindProperty ( "m_EditorData.packingParameters .enableRotation" ) ;
191- m_Padding = serializedObject . FindProperty ( "m_EditorData.packingParameters .padding" ) ;
179+ m_EnableTightPacking = serializedObject . FindProperty ( "m_EditorData.packingSettings .enableTightPacking" ) ;
180+ m_EnableRotation = serializedObject . FindProperty ( "m_EditorData.packingSettings .enableRotation" ) ;
181+ m_Padding = serializedObject . FindProperty ( "m_EditorData.packingSettings .padding" ) ;
192182
193183 m_MasterAtlas = serializedObject . FindProperty ( "m_MasterAtlas" ) ;
194184 m_BindAsDefault = serializedObject . FindProperty ( "m_EditorData.bindAsDefault" ) ;
195- m_VariantMultiplier = serializedObject . FindProperty ( "m_EditorData.variantMultiplier" ) ;
185+ m_VariantScale = serializedObject . FindProperty ( "m_EditorData.variantMultiplier" ) ;
196186
197187 m_Packables = serializedObject . FindProperty ( "m_EditorData.packables" ) ;
198188 m_PackableList = new ReorderableList ( serializedObject , m_Packables , true , true , true , true ) ;
@@ -218,18 +208,10 @@ void SyncPlatformSettings()
218208
219209 // Default platform
220210 var defaultSettings = new List < TextureImporterPlatformSettings > ( ) ;
221- m_TempPlatformSettings . Add ( kDefaultPlatformName , defaultSettings ) ;
222- foreach ( var t in targets )
211+ m_TempPlatformSettings . Add ( TextureImporterInspector . s_DefaultPlatformName , defaultSettings ) ;
212+ foreach ( SpriteAtlas sa in targets )
223213 {
224- TextureImporterPlatformSettings settings = new TextureImporterPlatformSettings ( ) ;
225- settings . name = kDefaultPlatformName ;
226-
227- SerializedObject targetSerializedObject = new SerializedObject ( t ) ;
228- settings . maxTextureSize = targetSerializedObject . FindProperty ( "m_EditorData.textureSettings.maxTextureSize" ) . intValue ;
229- settings . textureCompression = ( TextureImporterCompression ) targetSerializedObject . FindProperty ( "m_EditorData.textureSettings.textureCompression" ) . enumValueIndex ;
230- settings . crunchedCompression = targetSerializedObject . FindProperty ( "m_EditorData.textureSettings.crunchedCompression" ) . boolValue ;
231- settings . compressionQuality = targetSerializedObject . FindProperty ( "m_EditorData.textureSettings.compressionQuality" ) . intValue ;
232-
214+ var settings = sa . GetPlatformSettings ( TextureImporterInspector . s_DefaultPlatformName ) ;
233215 defaultSettings . Add ( settings ) ;
234216 }
235217
@@ -240,9 +222,7 @@ void SyncPlatformSettings()
240222 m_TempPlatformSettings . Add ( platform . name , platformSettings ) ;
241223 foreach ( SpriteAtlas sa in targets )
242224 {
243- TextureImporterPlatformSettings settings = new TextureImporterPlatformSettings ( ) ;
244- settings . name = platform . name ;
245- sa . CopyPlatformSettingsIfAvailable ( platform . name , settings ) ;
225+ var settings = sa . GetPlatformSettings ( platform . name ) ;
246226
247227 // setting will be in default state if copy failed
248228 platformSettings . Add ( settings ) ;
@@ -383,10 +363,10 @@ private void HandleCommonSettingUI()
383363 private void HandleVariantSettingUI ( )
384364 {
385365 EditorGUILayout . LabelField ( s_Styles . variantSettingLabel , EditorStyles . boldLabel ) ;
386- EditorGUILayout . PropertyField ( m_VariantMultiplier , s_Styles . variantMultiplierLabel ) ;
366+ EditorGUILayout . PropertyField ( m_VariantScale , s_Styles . variantMultiplierLabel ) ;
387367
388368 // Test if the multiplier scale a power of two size (1024) into another power of 2 size.
389- if ( ! Mathf . IsPowerOfTwo ( ( int ) ( m_VariantMultiplier . floatValue * 1024 ) ) )
369+ if ( ! Mathf . IsPowerOfTwo ( ( int ) ( m_VariantScale . floatValue * 1024 ) ) )
390370 EditorGUILayout . HelpBox ( s_Styles . notPowerOfTwoWarning . text , MessageType . Warning , true ) ;
391371 }
392372
@@ -436,36 +416,21 @@ private void HandlePlatformSettingUI()
436416 int shownTextureFormatPage = EditorGUILayout . BeginPlatformGrouping ( m_ValidPlatforms . ToArray ( ) , s_Styles . defaultPlatformLabel ) ;
437417 if ( shownTextureFormatPage == - 1 )
438418 {
439- List < TextureImporterPlatformSettings > platformSettings = m_TempPlatformSettings [ kDefaultPlatformName ] ;
440- List < TextureImporterPlatformSettings > newSettings = new List < TextureImporterPlatformSettings > ( platformSettings . Count ) ;
441- for ( var i = 0 ; i < platformSettings . Count ; ++ i )
442- {
443- TextureImporterPlatformSettings settings = new TextureImporterPlatformSettings ( ) ;
444- platformSettings [ i ] . CopyTo ( settings ) ;
445- newSettings . Add ( settings ) ;
446- }
447-
448- if ( m_TexturePlatformSettingsController . HandleDefaultSettings ( newSettings , m_TexturePlatformSettingsView ) )
419+ var platformSettings = m_TempPlatformSettings [ TextureImporterInspector . s_DefaultPlatformName ] ;
420+ if ( m_TexturePlatformSettingsController . HandleDefaultSettings ( platformSettings , m_TexturePlatformSettingsView ) )
449421 {
450- for ( var i = 0 ; i < newSettings . Count ; ++ i )
422+ for ( var i = 0 ; i < platformSettings . Count ; ++ i )
451423 {
452- if ( platformSettings [ i ] . maxTextureSize != newSettings [ i ] . maxTextureSize )
453- m_MaxTextureSize . intValue = newSettings [ i ] . maxTextureSize ;
454- if ( platformSettings [ i ] . textureCompression != newSettings [ i ] . textureCompression )
455- m_TextureCompression . enumValueIndex = ( int ) newSettings [ i ] . textureCompression ;
456- if ( platformSettings [ i ] . crunchedCompression != newSettings [ i ] . crunchedCompression )
457- m_UseCrunchedCompression . boolValue = newSettings [ i ] . crunchedCompression ;
458- if ( platformSettings [ i ] . compressionQuality != newSettings [ i ] . compressionQuality )
459- m_CompressionQuality . intValue = newSettings [ i ] . compressionQuality ;
460-
461- newSettings [ i ] . CopyTo ( platformSettings [ i ] ) ;
424+ SpriteAtlas sa = ( SpriteAtlas ) targets [ i ] ;
425+ sa . SetPlatformSettings ( platformSettings [ i ] ) ;
462426 }
463427 }
464428 }
465429 else
466430 {
467- BuildPlatform buildPlatform = m_ValidPlatforms [ shownTextureFormatPage ] ;
468- List < TextureImporterPlatformSettings > platformSettings = m_TempPlatformSettings [ buildPlatform . name ] ;
431+ var buildPlatform = m_ValidPlatforms [ shownTextureFormatPage ] ;
432+ var platformSettings = m_TempPlatformSettings [ buildPlatform . name ] ;
433+
469434
470435 // Predetermine format if overridden is unchecked
471436 for ( var i = 0 ; i < platformSettings . Count ; ++ i )
@@ -474,7 +439,7 @@ private void HandlePlatformSettingUI()
474439 if ( ! settings . overridden )
475440 {
476441 SpriteAtlas sa = ( SpriteAtlas ) targets [ i ] ;
477- settings . format = sa . FormatDetermineByAtlasSettings ( buildPlatform . defaultTarget ) ;
442+ settings . format = ( TextureImporterFormat ) sa . GetTextureFormat ( buildPlatform . defaultTarget ) ;
478443 }
479444 }
480445
@@ -572,10 +537,10 @@ private void HandlePackableListUI()
572537
573538 void CachePreviewTexture ( )
574539 {
575- if ( m_PreviewTextures == null || m_Hash != spriteAtlas . GetHashString ( ) )
540+ if ( m_PreviewTextures == null || m_Hash != spriteAtlas . GetHash ( ) )
576541 {
577542 m_PreviewTextures = spriteAtlas . GetPreviewTextures ( ) ;
578- m_Hash = spriteAtlas . GetHashString ( ) ;
543+ m_Hash = spriteAtlas . GetHash ( ) ;
579544
580545 if ( m_PreviewTextures != null
581546 && m_PreviewTextures . Length > 0
0 commit comments