Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetIcon()

Gets the icon to associate with the imported MonoScript.
Read time 1 minuteLast updated 10 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule
public Texture2D GetIcon()

Returns

Type

Description

Texture2DReturns the custom icon that will be associated with the imported MonoScript. If no custom icon will be associated with the imported MonoScript, returns null.

Remarks

Examples

using UnityEngine;using UnityEditor;class Example{ [MenuItem("Examples/Get Icon for MonoScript from MonoImporter")] public static void GetIconForMonoScriptFromMonoImporter() { var assetPath = "Assets/MyMonoBehaviour.cs"; var monoImporter = AssetImporter.GetAtPath(assetPath) as MonoImporter; var icon = monoImporter.GetIcon(); Debug.Log($"Icon for {assetPath} is {icon}"); }}