PO/Library/PackageCache/com.unity.2d.animation@5.0.7/Editor/SkinningModule/IconUtility.cs

31 lines
1.1 KiB
C#
Raw Normal View History

2022-01-12 10:06:03 +03:00
using System.IO;
using UnityEngine;
namespace UnityEditor.U2D.Animation
{
internal static class IconUtility
{
static public readonly string k_LightIconResourcePath = "SkinningModule/Icons/Light";
static public readonly string k_DarkIconResourcePath = "SkinningModule/Icons/Dark";
static public readonly string k_SelectedResourceIconPath = "SkinningModule/Icons/Selected";
public static Texture2D LoadIconResource(string name, string personalPath, string proPath)
{
string iconPath = "";
if (EditorGUIUtility.isProSkin && !string.IsNullOrEmpty(proPath))
iconPath = Path.Combine(proPath, "d_" + name);
else
iconPath = Path.Combine(personalPath, name);
if (EditorGUIUtility.pixelsPerPoint > 1.0f)
{
var icon2x = ResourceLoader.Load<Texture2D>(iconPath + "@2x.png");
if (icon2x != null)
return icon2x;
}
return ResourceLoader.Load<Texture2D>(iconPath+".png");
}
}
}