com.alicizax.unity.editor.e.../Editor/Postprocessor/Atlas/AtlasPostprocessor.cs

39 lines
1.1 KiB
C#
Raw Normal View History

2025-03-11 17:46:52 +08:00
#if AtlasProcessorKey
using UnityEditor;
using UnityEngine;
public class AtlasPostprocessor : AssetPostprocessor
{
private static AtlasConfiguration config;
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets,
string[] movedAssets, string[] movedFromAssetPaths)
{
if (config == null)
{
config = AtlasConfiguration.instance;
}
if (config == null) return;
foreach (var path in importedAssets) HandleAsset(path);
foreach (var path in movedAssets) HandleAsset(path);
foreach (var path in deletedAssets) HandleDeletedAsset(path);
foreach (var path in movedFromAssetPaths) HandleDeletedAsset(path);
}
private static void HandleAsset(string path)
{
if (path.EndsWith(".png") || path.EndsWith(".jpg"))
{
AtlasProcessor.ProcessSingleSprite(path, config);
}
}
private static void HandleDeletedAsset(string path)
{
// Handle removed sprites from atlases
// Implementation depends on tracking system
}
}
#endif