# GetIconForObject(Object)

> Gets the custom icon associated with an object. Only GameObjects and MonoScripts have associated custom icons.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.5/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
public static Texture2D GetIconForObject(Object obj)
```

### Parameters

**** (\[Object]\(/engine/6000.5/script-reference/unityengine/object)): The [GameObject](/engine/6000.5/script-reference/unityengine/gameobject.md) or [MonoScript](/engine/6000.5/script-reference/unityeditor/monoscript.md) to query

### Returns

| Type                                                                  | Description                                                                                                              |
| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| [Texture2D](/engine/6000.5/script-reference/unityengine/texture2d.md) | Returns the custom icon associated with the object. If there is no custom icon associated with the object, returns null. |

### Examples

```csharp
using UnityEngine;
using UnityEditor;

class Example
{
    [MenuItem("Examples/Get Icon for GameObject")]
    public static void GetIconForGameObject()
    {
        var go = GameObject.Find("Main Camera");
        var icon = EditorGUIUtility.GetIconForObject(go);
        Debug.Log("Icon for " + go + " is " + icon);
    }

    [MenuItem("Examples/Get Icon for MonoScript")]
    public static void GetIconForMonoScript()
    {
        var monoScript = AssetDatabase.LoadAssetAtPath<MonoScript>("Assets/MyMonoBehaviour.cs");
        var icon = EditorGUIUtility.GetIconForObject(monoScript);
        Debug.Log("Icon for " + monoScript.GetClass().FullName + " is " + icon);
    }
}
```
