You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/Plugins/Smart-Inspector/Runtime/SmartInspector.Utils.Editor.cs

34 lines
937 B
C#

using System;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
namespace AV.Inspector.Runtime
{
public static partial class SmartInspector
{
public static Texture2D GetObjectIcon(Object obj, Type type = null)
{
Texture2D icon = null;
#if UNITY_EDITOR
icon = EditorGUIUtility.ObjectContent(obj, type ?? obj.GetType()).image as Texture2D;
#endif
return icon;
}
public static Texture2D GetTypeIcon<T>() => GetTypeIcon(typeof(T));
public static Texture2D GetTypeIcon(Type type)
{
return GetObjectIcon(null, type);
}
public static Texture2D GetEditorIcon(string iconName)
{
Texture2D icon = null;
#if UNITY_EDITOR
icon = EditorGUIUtility.IconContent(iconName).image as Texture2D;
#endif
return icon;
}
}
}