AtlasInfo.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using UnityEditor;
  3. using UnityEditor.Presets;
  4. namespace XGame.Editor.Asset
  5. {
  6. [Serializable]
  7. public class AtlasInfo
  8. {
  9. internal static AtlasInfo DefaultInfo()
  10. {
  11. return new AtlasInfo()
  12. {
  13. packerMode = SpritePackerMode.Atlas,
  14. atlasLayerLimit = 3,
  15. spriteAtlasPreset = DefaultPreset,
  16. };
  17. }
  18. public SpritePackerMode packerMode;
  19. /// <summary>
  20. /// 图集文件夹子目录的遍历上限
  21. /// 超过上限的视为同一个图集
  22. /// </summary>
  23. public byte atlasLayerLimit;
  24. /// <summary>
  25. /// 图集预设
  26. /// </summary>
  27. public Preset spriteAtlasPreset;
  28. /// <summary>
  29. /// 图集名命名类型
  30. /// 0:tag+文件夹名
  31. /// 1:文件夹路径
  32. /// 2:guid
  33. /// </summary>
  34. public int atlasNameType;
  35. private static Preset DefaultPreset
  36. {
  37. get
  38. {
  39. var guids = AssetDatabase.FindAssets("SpriteAtlasTemplate");
  40. if (guids.Length > 0)
  41. {
  42. var assetPath = AssetDatabase.GUIDToAssetPath(guids[0]);
  43. return AssetDatabase.LoadAssetAtPath<Preset>(assetPath);
  44. }
  45. return null;
  46. }
  47. }
  48. }
  49. }