className | 此插件导入的 MonoScript 的完全限定类名。 |
Texture2D 返回将与导入的 MonoScript 关联的自定义图标。如果没有自定义图标将与导入的 MonoScript 关联,则返回 null。
在导入时获取要与 MonoScript 关联的自定义图标。
其他资源:MonoScript.GetClass、Type.FullName、PluginImporter.SetIcon、EditorGUIUtility.GetIconForObject。
using UnityEngine; using UnityEditor;
class Example { [MenuItem("Examples/Get Icon for MonoScript from PluginImporter")] public static void GetIconForMonoScriptFromPluginImporter() { var assetPath = "Assets/MyManagedPlugin.dll"; var pluginImporter = AssetImporter.GetAtPath(assetPath) as PluginImporter; var monoScript = AssetDatabase.LoadAssetAtPath<MonoScript>(assetPath);
var icon = pluginImporter.GetIcon(monoScript.GetClass().FullName); Debug.Log("Icon for " + monoScript.GetClass().FullName + " in " + assetPath + " is " + icon); } }