Postprocess.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. namespace AtlasUtility
  2. {
  3. using UnityEditor;
  4. using System.IO;
  5. using System.Collections.Generic;
  6. public class Postprocess : AssetPostprocessor
  7. {
  8. public static void OnPostprocessAllAssets(string[] importedPathes, string[] deletedPathes, string[] movedPathes, string[] movedFromAssetPathes)
  9. {
  10. List<string> pngPathList = new List<string>();
  11. for (int i = 0; i < deletedPathes.Length; i++)
  12. {
  13. if (Path.GetExtension(deletedPathes[i]) == ".png")
  14. {
  15. pngPathList.Add(deletedPathes[i]);
  16. }
  17. }
  18. if (pngPathList.Count == 0)
  19. {
  20. return;
  21. }
  22. List<string> guidList = GUIDManager.GetGUID(pngPathList);
  23. List<AtlasReferencePair> referencePairList = AtlasReferenceManager.GetReferencePair(guidList);
  24. AtlasReferenceManager.RemoveReferencePair(referencePairList);
  25. PlatformReferenceManager.RemoveReference(guidList);
  26. List<AtlasReference> fromReferenceList = new List<AtlasReference>();
  27. List<AtlasReference> toReferenceList = new List<AtlasReference>();
  28. foreach (var referencePair in referencePairList)
  29. {
  30. fromReferenceList.Add(referencePair.AtlasReference);
  31. toReferenceList.Add(referencePair.SourceAtlasReference);
  32. }
  33. AtlasReferenceManager.ChangeReference(fromReferenceList, toReferenceList);
  34. }
  35. }
  36. }