> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksiconutility.md).

# Class ksIconUtility

Namespace: [KS.Unity.Editor](/reactor/api-reference/ks.unity.editor.md)\
Assembly: KSUnity-Editor.dll

Utility for setting icons for Unity objects. Uses reflection to call a Unity private method because Unity does not expose icons to the API. Icons set with this utility are not saved and will be cleared when Unity is closed or when the script's code changes, so the icons need to be set each time Unity loads.

```csharp
public class ksIconUtility
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksIconUtility](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksiconutility.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Methods

### ApplyInheritedIcons(params string\[]) <a href="#ks_unity_editor_ksiconutility_applyinheritedicons_system_string" id="ks_unity_editor_ksiconutility_applyinheritedicons_system_string"></a>

Applies inherited icons set with [SetInheritedIcon](#KS_Unity_Editor_ksIconUtility_SetInheritedIcon_System_Type_2cUnityEngine_Texture2D_2cSystem_Boolean_2cSystem_Boolean_) to scripts.

```csharp
public void ApplyInheritedIcons(params string[] referencedAssemblies)
```

#### Parameters

`referencedAssemblies` [string](https://learn.microsoft.com/dotnet/api/system.string)\[]

Searches these assemblies and assemblies that reference these assemblies for scripts to apply icons to. If null or empty, searches all assemblies.

### Get() <a href="#ks_unity_editor_ksiconutility_get" id="ks_unity_editor_ksiconutility_get"></a>

Gets the singleton instance.

```csharp
public static ksIconUtility Get()
```

#### Returns

[ksIconUtility](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksiconutility.md)

### GetBuiltInIcons() <a href="#ks_unity_editor_ksiconutility_getbuiltinicons" id="ks_unity_editor_ksiconutility_getbuiltinicons"></a>

Gets the array of built-in icons.

```csharp
public Texture2D[] GetBuiltInIcons()
```

#### Returns

Texture2D\[]

icons

### SetDisabledIcon\<T>(Texture2D, bool) <a href="#ks_unity_editor_ksiconutility_setdisabledicon__1_unityengine_texture2d_system_boolean" id="ks_unity_editor_ksiconutility_setdisabledicon__1_unityengine_texture2d_system_boolean"></a>

Sets the icon for a monobehaviour and disables it from appearing in the scene view.

```csharp
public bool SetDisabledIcon<T>(Texture2D texture, bool overwrite = false) where T : MonoBehaviour
```

#### Parameters

`texture` Texture2D

Texture to set for the icon.

`overwrite` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, will not set or disable the icon if the script already has an icon.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the icon was set successfully.

#### Type Parameters

`T`

Type of monobehaviour to set disabled icon for.

### SetDisabledIcon(Type, Texture2D, bool) <a href="#ks_unity_editor_ksiconutility_setdisabledicon_system_type_unityengine_texture2d_system_boolean" id="ks_unity_editor_ksiconutility_setdisabledicon_system_type_unityengine_texture2d_system_boolean"></a>

Sets the icon for a script type and disables it from appearing in the scene view if it is a type of monobehaviour.

```csharp
public bool SetDisabledIcon(Type type, Texture2D texture, bool overwrite = false)
```

#### Parameters

`type` [Type](https://learn.microsoft.com/dotnet/api/system.type)

`texture` Texture2D

Texture to set for the icon.

`overwrite` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, will not set or disable the icon if the script already has an icon.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the icon was set successfully.

### SetIcon(Object, Icon, bool) <a href="#ks_unity_editor_ksiconutility_seticon_unityengine_object_ks_unity_editor_ksiconutility_icon_system_b" id="ks_unity_editor_ksiconutility_seticon_unityengine_object_ks_unity_editor_ksiconutility_icon_system_b"></a>

Sets the icon for an object.

```csharp
public bool SetIcon(Object obj, ksIconUtility.Icon icon, bool overwrite = false)
```

#### Parameters

`obj` Object

obj to set icon for.

`icon` [ksIconUtility](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksiconutility.md).[Icon](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksiconutility/ks.unity.editor.ksiconutility.icon.md)

icon to set.

`overwrite` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, will not set the icon if the object already has an icon.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the icon was set successfully.

### SetIcon\<T>(Icon, bool) <a href="#ks_unity_editor_ksiconutility_seticon__1_ks_unity_editor_ksiconutility_icon_system_boolean" id="ks_unity_editor_ksiconutility_seticon__1_ks_unity_editor_ksiconutility_icon_system_boolean"></a>

Sets the icon for script type T.

```csharp
public bool SetIcon<T>(ksIconUtility.Icon icon, bool overwrite = false) where T : MonoBehaviour
```

#### Parameters

`icon` [ksIconUtility](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksiconutility.md).[Icon](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksiconutility/ks.unity.editor.ksiconutility.icon.md)

icon to set.

`overwrite` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, will not set the icon if the object already has an icon.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the icon was set successfully.

#### Type Parameters

`T`

### SetIcon(Type, Icon, bool) <a href="#ks_unity_editor_ksiconutility_seticon_system_type_ks_unity_editor_ksiconutility_icon_system_boolean" id="ks_unity_editor_ksiconutility_seticon_system_type_ks_unity_editor_ksiconutility_icon_system_boolean"></a>

Sets the icon for script type.

```csharp
public bool SetIcon(Type type, ksIconUtility.Icon icon, bool overwrite = false)
```

#### Parameters

`type` [Type](https://learn.microsoft.com/dotnet/api/system.type)

type of script to set icon for.

`icon` [ksIconUtility](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksiconutility.md).[Icon](/reactor/api-reference/ks.unity.editor/ks.unity.editor.ksiconutility/ks.unity.editor.ksiconutility.icon.md)

icon to set.

`overwrite` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, will not set the icon if the object already has an icon.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the icon was set successfully.

### SetIcon(Object, Texture2D, bool) <a href="#ks_unity_editor_ksiconutility_seticon_unityengine_object_unityengine_texture2d_system_boolean" id="ks_unity_editor_ksiconutility_seticon_unityengine_object_unityengine_texture2d_system_boolean"></a>

Sets the icon for an object.

```csharp
public bool SetIcon(Object obj, Texture2D texture, bool overwrite = false)
```

#### Parameters

`obj` Object

obj to set icon for.

`texture` Texture2D

texture for icon to set.

`overwrite` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, will not set the icon if the object already has an icon.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the icon was set successfully.

### SetIcon\<T>(Texture2D, bool) <a href="#ks_unity_editor_ksiconutility_seticon__1_unityengine_texture2d_system_boolean" id="ks_unity_editor_ksiconutility_seticon__1_unityengine_texture2d_system_boolean"></a>

Sets the icon for script type T.

```csharp
public bool SetIcon<T>(Texture2D texture, bool overwrite = false) where T : Object
```

#### Parameters

`texture` Texture2D

texture for icon to set.

`overwrite` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, will not set the icon if the object already has an icon.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the icon was set successfully.

#### Type Parameters

`T`

### SetIcon(Type, Texture2D, bool) <a href="#ks_unity_editor_ksiconutility_seticon_system_type_unityengine_texture2d_system_boolean" id="ks_unity_editor_ksiconutility_seticon_system_type_unityengine_texture2d_system_boolean"></a>

Sets the icon for script type.

```csharp
public bool SetIcon(Type type, Texture2D texture, bool overwrite = false)
```

#### Parameters

`type` [Type](https://learn.microsoft.com/dotnet/api/system.type)

type of script to set icon for.

`texture` Texture2D

texture for icon to set.

`overwrite` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, will not set the icon if the object already has an icon.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the icon was set successfully.

### SetIconEnabled\<T>(bool) <a href="#ks_unity_editor_ksiconutility_seticonenabled__1_system_boolean" id="ks_unity_editor_ksiconutility_seticonenabled__1_system_boolean"></a>

Sets the enabled state of an icon for a monobehaviour. Disabling an icon prevents it from appearing in the scene view.

```csharp
public void SetIconEnabled<T>(bool enabled) where T : MonoBehaviour
```

#### Parameters

`enabled` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

Enabled state to set.

#### Type Parameters

`T`

Type of monobehaviour to set icon enabled state for.

### SetIconEnabled(Type, bool) <a href="#ks_unity_editor_ksiconutility_seticonenabled_system_type_system_boolean" id="ks_unity_editor_ksiconutility_seticonenabled_system_type_system_boolean"></a>

Sets the enabled state of an icon for a monobehaviour. Disabling an icon prevents it from appearing in the scene view.

```csharp
public void SetIconEnabled(Type type, bool enabled)
```

#### Parameters

`type` [Type](https://learn.microsoft.com/dotnet/api/system.type)

Type of monobehaviour to set icon enabled state for. Does nothing if this is not a type of monobehaviour.

`enabled` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

Enabled state to set.

### SetInheritedIcon\<T>(Texture2D, bool, bool) <a href="#ks_unity_editor_ksiconutility_setinheritedicon__1_unityengine_texture2d_system_boolean_system_boolea" id="ks_unity_editor_ksiconutility_setinheritedicon__1_unityengine_texture2d_system_boolean_system_boolea"></a>

Sets the icon for script type `T` and all scripts that inherit from it. The icons will not be applied until you call [ApplyInheritedIcons](#KS_Unity_Editor_ksIconUtility_ApplyInheritedIcons_System_String_5b_5d_). If a script inherits from multiple scripts with inherited icons, it will inherit the icon from the closest base class in the inheritance chain.

```csharp
public void SetInheritedIcon<T>(Texture2D texture, bool overwrite = false, bool disabled = true) where T : Object
```

#### Parameters

`texture` Texture2D

Texture to set for the icon.

`overwrite` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, will not set the icon for scripts that already have an icon.

`disabled` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If true and the script is a component type, disables the icon to prevent it from appearing in the scene view.

#### Type Parameters

`T`

Type of script to set inherited icon for.

### SetInheritedIcon(Type, Texture2D, bool, bool) <a href="#ks_unity_editor_ksiconutility_setinheritedicon_system_type_unityengine_texture2d_system_boolean_syst" id="ks_unity_editor_ksiconutility_setinheritedicon_system_type_unityengine_texture2d_system_boolean_syst"></a>

Sets the icon for script `type` and all scripts that inherit from it. The icons will not be applied until you call [ApplyInheritedIcons](#KS_Unity_Editor_ksIconUtility_ApplyInheritedIcons_System_String_5b_5d_). If a script inherits from multiple scripts with inherited icons, it will inherit the icon from the closest base class in the inheritance chain.

```csharp
public void SetInheritedIcon(Type type, Texture2D texture, bool overwrite = false, bool disabled = true)
```

#### Parameters

`type` [Type](https://learn.microsoft.com/dotnet/api/system.type)

Type of script to set inherited icon for.

`texture` Texture2D

Texture to set for the icon.

`overwrite` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If false, will not set the icon for scripts that already have an icon.

`disabled` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

If true and the script is a component type, disables the icon to prevent it from appearing in the scene view.
