mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Atlas工具增加2021版本支持
目前支持2021.x ~ 6000.x
This commit is contained in:
@@ -173,10 +173,16 @@
|
|||||||
spriteAtlasAsset.Add(sprites.ToArray());
|
spriteAtlasAsset.Add(sprites.ToArray());
|
||||||
SpriteAtlasAsset.Save(spriteAtlasAsset, outputPath);
|
SpriteAtlasAsset.Save(spriteAtlasAsset, outputPath);
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
|
|
||||||
EditorApplication.delayCall += () =>
|
EditorApplication.delayCall += () =>
|
||||||
{
|
{
|
||||||
|
#if UNITY_2022_1_OR_NEWER
|
||||||
SpriteAtlasImporter sai = (SpriteAtlasImporter)AssetImporter.GetAtPath(outputPath);
|
SpriteAtlasImporter sai = (SpriteAtlasImporter)AssetImporter.GetAtPath(outputPath);
|
||||||
ConfigureAtlasV2Settings(sai);
|
ConfigureAtlasV2Settings(sai);
|
||||||
|
#else
|
||||||
|
ConfigureAtlasV2Settings(spriteAtlasAsset);
|
||||||
|
SpriteAtlasAsset.Save(spriteAtlasAsset, outputPath);
|
||||||
|
#endif
|
||||||
AssetDatabase.WriteImportSettingsIfDirty(outputPath);
|
AssetDatabase.WriteImportSettingsIfDirty(outputPath);
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
};
|
};
|
||||||
@@ -203,6 +209,8 @@
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if UNITY_2022_1_OR_NEWER
|
||||||
private static void ConfigureAtlasV2Settings(SpriteAtlasImporter atlasImporter)
|
private static void ConfigureAtlasV2Settings(SpriteAtlasImporter atlasImporter)
|
||||||
{
|
{
|
||||||
void SetPlatform(string platform, TextureImporterFormat format)
|
void SetPlatform(string platform, TextureImporterFormat format)
|
||||||
@@ -215,6 +223,34 @@
|
|||||||
settings.compressionQuality = Config.compressionQuality;
|
settings.compressionQuality = Config.compressionQuality;
|
||||||
atlasImporter.SetPlatformSettings(settings);
|
atlasImporter.SetPlatformSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetPlatform("Android", Config.androidFormat);
|
||||||
|
SetPlatform("iPhone", Config.iosFormat);
|
||||||
|
SetPlatform("WebGL", Config.webglFormat);
|
||||||
|
|
||||||
|
var packingSettings = new SpriteAtlasPackingSettings
|
||||||
|
{
|
||||||
|
padding = Config.padding,
|
||||||
|
enableRotation = Config.enableRotation,
|
||||||
|
blockOffset = Config.blockOffset,
|
||||||
|
enableTightPacking = Config.tightPacking,
|
||||||
|
enableAlphaDilation = true
|
||||||
|
};
|
||||||
|
atlasImporter.packingSettings = packingSettings;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
private static void ConfigureAtlasV2Settings(SpriteAtlasAsset spriteAtlasAsset)
|
||||||
|
{
|
||||||
|
void SetPlatform(string platform, TextureImporterFormat format)
|
||||||
|
{
|
||||||
|
var settings = spriteAtlasAsset.GetPlatformSettings(platform);
|
||||||
|
if (settings == null) return;
|
||||||
|
;
|
||||||
|
settings.overridden = true;
|
||||||
|
settings.format = format;
|
||||||
|
settings.compressionQuality = Config.compressionQuality;
|
||||||
|
spriteAtlasAsset.SetPlatformSettings(settings);
|
||||||
|
}
|
||||||
|
|
||||||
SetPlatform("Android", Config.androidFormat);
|
SetPlatform("Android", Config.androidFormat);
|
||||||
SetPlatform("iPhone", Config.iosFormat);
|
SetPlatform("iPhone", Config.iosFormat);
|
||||||
@@ -228,8 +264,10 @@
|
|||||||
enableTightPacking = Config.tightPacking,
|
enableTightPacking = Config.tightPacking,
|
||||||
enableAlphaDilation = true
|
enableAlphaDilation = true
|
||||||
};
|
};
|
||||||
atlasImporter.packingSettings = packingSettings;
|
spriteAtlasAsset.SetPackingSettings(packingSettings);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
private static void ConfigureAtlasSettings(SpriteAtlas atlas)
|
private static void ConfigureAtlasSettings(SpriteAtlas atlas)
|
||||||
{
|
{
|
||||||
@@ -251,6 +289,7 @@
|
|||||||
padding = Config.padding,
|
padding = Config.padding,
|
||||||
enableRotation = Config.enableRotation,
|
enableRotation = Config.enableRotation,
|
||||||
blockOffset = Config.blockOffset,
|
blockOffset = Config.blockOffset,
|
||||||
|
enableTightPacking = Config.tightPacking,
|
||||||
};
|
};
|
||||||
atlas.SetPackingSettings(packingSettings);
|
atlas.SetPackingSettings(packingSettings);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user