IconUtility.cs 1.1 KB

123456789101112131415161718192021222324252627282930
  1. using System.IO;
  2. using UnityEngine;
  3. namespace UnityEditor.U2D.Animation
  4. {
  5. internal static class IconUtility
  6. {
  7. static public readonly string k_LightIconResourcePath = "SkinningModule/Icons/Light";
  8. static public readonly string k_DarkIconResourcePath = "SkinningModule/Icons/Dark";
  9. static public readonly string k_SelectedResourceIconPath = "SkinningModule/Icons/Selected";
  10. public static Texture2D LoadIconResource(string name, string personalPath, string proPath)
  11. {
  12. string iconPath = "";
  13. if (EditorGUIUtility.isProSkin && !string.IsNullOrEmpty(proPath))
  14. iconPath = Path.Combine(proPath, "d_" + name);
  15. else
  16. iconPath = Path.Combine(personalPath, name);
  17. if (EditorGUIUtility.pixelsPerPoint > 1.0f)
  18. {
  19. var icon2x = ResourceLoader.Load<Texture2D>(iconPath + "@2x.png");
  20. if (icon2x != null)
  21. return icon2x;
  22. }
  23. return ResourceLoader.Load<Texture2D>(iconPath+".png");
  24. }
  25. }
  26. }