| | |
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | int sourceWidth;
|
| | | int sourceHeight;
|
| | | textureImporter.GetSourceTextureWidthAndHeight(out sourceWidth, out sourceHeight);
|
| | | if (sourceWidth > TexturePlatformFormatHelper.ATLAS_MAX_SIZE
|
| | | || sourceHeight > TexturePlatformFormatHelper.ATLAS_MAX_SIZE)
|
| | | {
|
| | | count++;
|
| | | EditorUtility.DisplayProgressBar(StringUtility.Concat("设置图集标签:", setting.folderName), file.Name, count / (float)total);
|
| | | continue;
|
| | | }
|
| | |
|
| | | bool isChange = false;
|
| | | if (textureImporter.textureType != TextureImporterType.Sprite)
|
| | | {
|
| | |
| | | new SpriteSettingConfig.PlatformSetting()
|
| | | {
|
| | | name = "Android",
|
| | | maxTextureSize = 2048,
|
| | | maxTextureSize = TexturePlatformFormatHelper.ATLAS_MAX_SIZE,
|
| | | textureCompression = TextureImporterCompression.Compressed,
|
| | | textureFormat = TextureImporterFormat.ASTC_6x6
|
| | | },
|
| | | new SpriteSettingConfig.PlatformSetting()
|
| | | {
|
| | | name = "iPhone",
|
| | | maxTextureSize = 2048,
|
| | | maxTextureSize = TexturePlatformFormatHelper.ATLAS_MAX_SIZE,
|
| | | textureCompression = TextureImporterCompression.Compressed,
|
| | | textureFormat = TextureImporterFormat.ASTC_6x6
|
| | | }
|
| | |
| | | {
|
| | | TextureImporterPlatformSettings settingPlatform = atlasImporter.GetPlatformSettings(platformSetting.name);
|
| | | settingPlatform.overridden = true;
|
| | | settingPlatform.maxTextureSize = platformSetting.maxTextureSize;
|
| | | settingPlatform.maxTextureSize = TexturePlatformFormatHelper.ATLAS_MAX_SIZE;
|
| | | settingPlatform.textureCompression = platformSetting.textureCompression;
|
| | | settingPlatform.format = platformSetting.textureFormat;
|
| | | atlasImporter.SetPlatformSettings(settingPlatform);
|
| | |
| | | List<UnityEngine.Object> objectsForPack = new List<UnityEngine.Object>();
|
| | | foreach (string item in textureFullName)
|
| | | {
|
| | | // 加载指定目录
|
| | | var textureImporter = AssetImporter.GetAtPath(item) as TextureImporter;
|
| | | if (textureImporter == null
|
| | | || textureImporter.textureType != TextureImporterType.Sprite
|
| | | || textureImporter.spriteImportMode == SpriteImportMode.None)
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | int sourceWidth;
|
| | | int sourceHeight;
|
| | | textureImporter.GetSourceTextureWidthAndHeight(out sourceWidth, out sourceHeight);
|
| | | if (sourceWidth > TexturePlatformFormatHelper.ATLAS_MAX_SIZE
|
| | | || sourceHeight > TexturePlatformFormatHelper.ATLAS_MAX_SIZE)
|
| | | {
|
| | | Debug.LogWarning($"[SpritePack] 跳过超过 {TexturePlatformFormatHelper.ATLAS_MAX_SIZE} 的贴图: {item} ({sourceWidth}x{sourceHeight})");
|
| | | continue;
|
| | | }
|
| | |
|
| | | UnityEngine.Object spriteObj = AssetDatabase.LoadAssetAtPath(item, typeof(UnityEngine.Object));
|
| | | //Debug.Log("存png和jpg后缀的图片: " + item + " , " + !packables.Contains(spriteObj));
|
| | | if (spriteObj == null)
|
| | | continue;
|
| | |
|
| | | if (!packables.Contains(spriteObj))
|
| | | {
|
| | | atlas.Add(new UnityEngine.Object[] { spriteObj });
|
| | |
| | |
|
| | |
|
| | | SpriteAtlasAsset.Save(atlas, filePath);
|
| | |
|
| | | var atlasImporter = SpriteAtlasImporter.GetAtPath(filePath) as SpriteAtlasImporter;
|
| | | if (atlasImporter != null && TexturePlatformFormatHelper.ApplyAtlasMaxTextureSize(atlasImporter))
|
| | | atlasImporter.SaveAndReimport();
|
| | | }
|
| | |
|
| | | /// <summary>
|