AssetIcons

Dynamic ScriptableObject Icons with a Single Attribute.

Designed to fit in seamlessly with current solutions, all you have to do:

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu]
5public class Item : ScriptableObject
6{
7 [AssetIcon]
8 public Sprite Icon;
9}

Features

Version 2.1.0 - Major Release

Released May 2020

New

API for creating AssetIcons addons

Created an API that allows users to customize and extend AssetIcons.

  Issue #30

New

Support for Unity Addressables Asset References

Utilised the API for expanding AssetIcons with new features to add support for Unity's Addressables.

  Issue #10

New

Updated preferences menu design

Now with clearer links for support and queries as well as a leave-a-review dialog.

  Issue #32

Changed

Removed allocations from the draw-loop

Optimized the draw-loop by removing allocations and expanding caching.

  Issue #17

Changed

Improved documentation look and feel

Improved the documentation styling with the new logo and new graphics.

  Issue #36

Fixed

Fixed issues when used alongside JetBrains.Rider plugin

Fixed compiler errors when using alongside JetBrains.Rider plugin by removing my compatibility-shim.

  Issue #35

Version 2.0.0 - Major Release

Released September 2019

New

Customizable icon styling

Customise the positioning, scale and more inside the AssetIconAttribute parameters.

  Issue #5

New

Support for multiple graphics

Added support for multiple graphics being rendered for a single asset.

  Issue #6

New

Support for rendering prefabs

Added support for rendering GameObject's to use as a ScriptableObject icon.

  Issue #2

New

Preferences menu

Added a tab to Unity's Preferences Window for customising AssetIcons.

  Issue #3

New

Update Checker

In-application update checker for AssetIcons.

  Issue #14

Changed

AssetIconAttribute removed from the Global Namespace

Moved AssetIconAttribute from the Global Namespace to "AssetIcons".

Changed

Cleaned up AssetIconDrawer APIs

Unified APIs for interfacing with AssetIcons' drawing tools.

Changed

Updated Documentation Format

Removed the PDF documentation in favour of interactive HTML documentation.

  Issue #4

Fixed

Made icons draw in "One-Column" mode

Fixed issue where icons weren't being drawn when in "One-Column" mode.

  Issue #26

Fixed

Add support for Unity-drawn flairs

Added support for Unity Collab (and other) flairs.

  Issue #25

Fixed

ReflectionTypeLoadException after code recompilation

This exception was being thrown after code recompilation only on certain environments.

  Issue #8

Removed

Modules System

Removed the old "Modules" system in favour of the preferences menu.

  Issue #16

Version 1.0.3 - Minor Release

Released April 2018

New

Modules System

Added the Modules System to render icons for files by their extension type.

Fixed

Fixes rendering Sprites when they are bundled

Fix rendering of sprites during play-mode when sprites are sprite-atlased to increase performance.

Version 1.0.0 - Initial Release

Released October 2017

New

Customizable ScriptableObject icons

Added the AssetIconAttribute to draw custom ScriptableObject icons.

  Issue #8

New

Custom Error Messages

Print log lines that open up to the location of the erroneous attribute.

New

Object Selector Support (2017.1 onwards)

Added support for rendering icons in the Object Selector Window.

Getting Started

To get started with AssetIcons, place the AssetIconAttribute on a member inside a ScriptableObject.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu]
5public class Item : ScriptableObject
6{
7 [AssetIcon]
8 public Sprite Icon;
9}

Next, assign values to the members flagged with the AssetIconAttribute.

If a value isn't assigned to the member that has the AssetIconAttribute attribute then it will just draw the default Unity icon.

You should now see the icons that you set appear on the ScriptableObject in the project window.

Preferences

AssetIcons can be configured in the Unity preferences menu. This configuration is per-user and per-project.

Issue Tracker

The first section of this dialog provides links for asking a question, reporting a bug, requesting a feature and finally listing all issues on the issue tracker.

Check for Updates

You can check for updates to AssetIcons from within the preferences menu. Pressing this button will open up a popup dialog (shown below).

Clicking on one of the versions in the Update Checker will open up the changelog hosted online.

AssetIcons can be updated from the Unity Asset Store.

Enabling and Disabling

You may enable and disable AssetIcons. This may be useful in collaborative projects where some users would rather not use AssetIcons, or for performance reasons it should be disabled.

Draw GUI Styles (Experimental)

Unity's GUI Styles can be represented as .asset files in the project window. AssetIcons can draw a preview of these GUI Styles right within the project window.

I don't see this feature being used much, and so it's included here as an experimental feature.

Prefab Resolution

You may adjust the resolution that AssetIcons renders Unity Prefabs to increase the quality of icons or increase performance with large amounts of assets.

Selection Tint

You may customise the strength of the selected asset tinting.

Type Icons

You may associate file extension types (.txt, .cs, e.t.c) with icons to customise your Unity editor experience.

Creating Extensions

AssetIcons supports "extensions" that allow users to add their own supported types.

To get started with creating your own extensions, you must first create an entrypoint for the extension. This is done by implementing the IAssetIconsExtension interface.

1using AssetIcons.Editors.Pipeline;
2
3public class BooleanAssetIconsExtension : IAssetIconsExtension
4{
5 public void Initialise(IAssetIconPipeline pipeline)
6 {
7 // Register your custom drawers here!
8 pipeline.RegisterDrawer(new BooleanGraphicDrawerFactory());
9 }
10}
11

Now that you have an entrypoint, you need to create the drawer factories that you want to register with AssetIcons.

1using AssetIcons.Editors;
2using AssetIcons.Editors.Pipeline;
3using System;
4using UnityEngine;
5
6public class BooleanGraphicDrawerFactory : IGraphicDrawerFactory
7{
8 private class BooleanGraphicDrawer : IGraphicDrawer
9 {
10 private bool hasValue;
11 private bool lastValue;
12
13 public bool CanDraw()
14 {
15 return hasValue;
16 }
17
18 public void Draw(Rect rect, bool selected, AssetIconsCompiledStyle style)
19 {
20 // Transform the rect of the icon in the Project window to the rect of the actual graphic.
21 var drawRect = AssetIconsGUIUtility.AreaToIconRect(rect, style.MaxSize);
22
23 // Using AssetIconsGUI allows us to draw stuff using the user-defined style.
24
25 if (lastValue)
26 {
27 // Draw a green square
28 AssetIconsGUI.DrawColor(drawRect, new Color32(0, 255, 0, 255), style, selected);
29 }
30 else
31 {
32 // Draw a red square
33 AssetIconsGUI.DrawColor(drawRect, new Color32(255, 0, 0, 255), style, selected);
34 }
35 }
36
37 public void SetValue(object value)
38 {
39 if (value != null)
40 {
41 lastValue = (bool)value;
42 hasValue = true;
43 }
44 else
45 {
46 hasValue = false;
47 }
48 }
49 }
50
51 public int Priority
52 {
53 get
54 {
55 // All of AssetIcons' drawers use 100 as a default value.
56 // The higher the priority, the more likely it is it will be used.
57 return 150;
58 }
59 }
60
61 public IGraphicDrawer CreateDrawer()
62 {
63 return new BooleanGraphicDrawer();
64 }
65
66 public bool IsValidFor(Type type)
67 {
68 return type == typeof(bool);
69 }
70}

AssetIconAttribute

Summary

Used to specify that this member controls the ScriptableObject's assets' icon.

Also see: AssetIconsStyle.

Definition

[AttributeUsage] public sealed class AssetIconAttribute : PropertyAttribute;

Example

In this example, we are using AssetIcons to draw a simple Sprite on a ScriptableObject.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon]
8 public Sprite Icon;
9}

We can also use CSS styling to modify the graphics drawn by this attribute. In this example we are going to remove the max size limit on icons and tint it purple.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(maxSize: 256)]
8 public Sprite Icon;
9
10 [AssetIcon(maxSize: 256, layer: -1, tint: "#000000ee")]
11 public Color GenerateBackground()
12 {
13 return Color.black;
14 }
15}

Instance Constructors

Constructors

Marks a field to be used as a graphic for a custom icon.

new AssetIconAttribute(
string width = "100%",
string height = "100%",
string x = "0",
string y = "0",
int maxSize = 64,
IconAnchor anchor = IconAnchor.Center,
IconAspect aspect = IconAspect.Fit,
string display = "true",
string tint = "#ffffff",
int layer = 0,
FontStyle fontStyle = FontStyle.Normal,
IconAnchor textAnchor = IconAnchor.Center,
IconProjection projection = IconProjection.Perspective
)

Instance Properties

Property Description

Style

A style defined in the constructor of the AssetIconAttribute.

FilePath

The local file path where this attribute is implemented.

LineNumber

The line number where this attribute implemented.

Remarks

This attribute can be placed on:

The AssetIconAttribute can be placed on the same member multiple times to draw the same graphic multiple times.

AssetIconAttribute.Style

Summary

A style defined in the constructor of the AssetIconAttribute.

Definition

public AssetIconsStyle Style { get; }

AssetIconAttribute.FilePath

Summary

The local file path where this attribute is implemented.

Also see: LineNumber.

Definition

public string FilePath { get; }

Remarks

This field only has a value in the editor and will return null outside of the editor.

AssetIconAttribute.LineNumber

Summary

The line number where this attribute implemented.

Also see: FilePath.

Definition

public int LineNumber { get; }

Remarks

This field only has a value in the editor and will return -1 outside of the editor.

IconAnchor

Summary

When changing the height, the anchor will change how much each side of the will change.

Using anchors is the fastest and easiest way to position elements in an icon.

Also see: AssetIconAttribute, AssetIconsStyle.

Definition

public enum IconAnchor;

Example

The AssetIconAttribute accepts an IconAnchor for styling.

Below is an example of the IconAnchor being used to create a bar at the bottom of the assets icon.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(anchor: IconAnchor.Bottom, height: "10%")]
8 public Color BottomBar { get; }
9}

Anchoring the asset to the bottom of the icon and then adjusting the height results in a bar on the bottom of the icon.

Anchoring the asset to corners of the icon can create handy annotations for assets.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(anchor: IconAnchor.TopLeft, height: "10%", width: "15%")]
8 public Color TopLeftTag { get; }
9}

Enum Values

Field Description

Center

Anchored to the center of the graphic. This enum has a value of 0.

Top

Anchored to the top of the graphic. This enum has a value of 1.

Bottom

Anchored to the bottom of the graphic. This enum has a value of 2.

Left

Anchored to the left of the graphic. This enum has a value of 3.

Right

Anchored to the right of the graphic. This enum has a value of 4.

TopLeft

Anchored to the top-left of the graphic. This enum has a value of 5.

TopRight

Anchored to the top-right of the graphic. This enum has a value of 6.

BottomLeft

Anchored to the bottom-left of the graphic. This enum has a value of 7.

BottomRight

Anchored to the bottom-right of the graphic. This enum has a value of 8.

IconAnchor.Center

Summary

Anchored to the center of the graphic.

Definition

IconAnchor.Center;

Example

The AssetIconAttribute accepts an IconAnchor for styling.

Below is an example of the "center" anchoring being used to shink the asset.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(anchor: IconAnchor.Center, width: "85%", height: "85%")]
8 public Color Icon { get; }
9}

Remarks

This is the default value for the styling of AssetIconAttribute.

IconAnchor.Top

Summary

Anchored to the top of the graphic.

Definition

IconAnchor.Top;

Example

The AssetIconAttribute accepts an IconAnchor for styling.

Below is an example of the "top" anchoring being used to create a bar at the top of the asset.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(anchor: IconAnchor.Top, height: "10%")]
8 public Color TopBar { get; }
9}

IconAnchor.Bottom

Summary

Anchored to the bottom of the graphic.

Definition

IconAnchor.Bottom;

Example

The AssetIconAttribute accepts an IconAnchor for styling.

Below is an example of the "bottom" anchoring being used to create a bar at the bottom of the asset.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(anchor: IconAnchor.Bottom, height: "10%")]
8 public Color BottomBar { get; }
9}

IconAnchor.Left

Summary

Anchored to the left of the graphic.

Definition

IconAnchor.Left;

Example

The AssetIconAttribute accepts an IconAnchor for styling.

Below is an example of the "left" anchoring being used to create a bar on the left of the asset.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(anchor: IconAnchor.Left, width: "15%")]
8 public Color LeftBar { get; }
9}

IconAnchor.Right

Summary

Anchored to the right of the graphic.

Definition

IconAnchor.Right;

Example

The AssetIconAttribute accepts an IconAnchor for styling.

Below is an example of the "right" anchoring being used to create a bar on the right of the asset.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(anchor: IconAnchor.Right, width: "15%")]
8 public Color RightBar { get; }
9}

IconAnchor.TopLeft

Summary

Anchored to the top-left of the graphic.

Definition

IconAnchor.TopLeft;

Example

The AssetIconAttribute accepts an IconAnchor for styling.

Below is an example of the "top-left" anchoring being used to create an icon in the top-left of the graphic..

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(anchor: IconAnchor.TopLeft, width: "20%", height: "10%")]
8 public Color SmallTag { get; }
9}

IconAnchor.TopRight

Summary

Anchored to the top-right of the graphic.

Definition

IconAnchor.TopRight;

Example

The AssetIconAttribute accepts an IconAnchor for styling.

Below is an example of the "top-right" anchoring being used to create an icon in the top-right of the graphic..

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(anchor: IconAnchor.TopRight, width: "20%", height: "10%")]
8 public Color SmallTag { get; }
9}

Remarks

It's not recommended to anchor small graphics in the top-right due to Unity Collab icon being drawn there.

IconAnchor.BottomLeft

Summary

Anchored to the bottom-left of the graphic.

Definition

IconAnchor.BottomLeft;

Example

The AssetIconAttribute accepts an IconAnchor for styling.

Below is an example of the "bottom-left" anchoring being used to create an icon in the bottom-left of the graphic..

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(anchor: IconAnchor.BottomLeft, width: "20%", height: "10%")]
8 public Color SmallTag { get; }
9}

IconAnchor.BottomRight

Summary

Anchored to the bottom-right of the graphic.

Definition

IconAnchor.BottomRight;

Example

The AssetIconAttribute accepts an IconAnchor for styling.

Below is an example of the "bottom-right" anchoring being used to create an icon in the bottom-right of the graphic..

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(anchor: IconAnchor.BottomRight, width: "20%", height: "10%")]
8 public Color SmallTag { get; }
9}

IconAspect

Summary

An enum that represents how the aspect ratio of a graphic should be used.

Also see: AssetIconAttribute, AssetIconsStyle.

Definition

public enum IconAspect;

Example

The AssetIconAttribute accepts an IconAspect for styling.

Below is an example of the IconAspect being force graphics to fit into the icon area.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(aspect: IconAspect.Fit)]
8 public Sprite ItemIcon { get; }
9}

Enum Values

Field Description

Fit

The rendered graphic should fit inside the Rect without any stretching. This enum has a value of 0.

Envelop

The rendered graphic should envelop the Rect without any stretching. This enum has a value of 1.

Stretch

The rendered graphic will stretch to the Rect dimensions. This enum has a value of 2.

IconAspect.Fit

Summary

The rendered graphic should fit inside the Rect without any stretching.

Also see: Envelop, Stretch.

Definition

IconAspect.Fit;

Example

The AssetIconAttribute accepts an IconAspect for styling.

Below is an example of the IconAspect being force graphics to fit into the icon area.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(aspect: IconAspect.Fit)]
8 public Sprite ItemIcon { get; }
9}

Remarks

This is the default value for the AssetIconAttribute.

IconAspect.Envelop

Summary

The rendered graphic should envelop the Rect without any stretching.

Also see: Fit, Stretch.

Definition

IconAspect.Envelop;

Example

The AssetIconAttribute accepts an IconAspect for styling.

Below is an example of the IconAspect being used to force graphics to envelop the icon area.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(aspect: IconAspect.Envelop)]
8 public Sprite ItemIcon { get; }
9}

IconAspect.Stretch

Summary

The rendered graphic will stretch to the Rect dimensions.

Also see: Fit, Envelop.

Definition

IconAspect.Stretch;

Example

The AssetIconAttribute accepts an IconAspect for styling.

Below is an example of the IconAspect being to force graphics to stretch across the icon area.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(aspect: IconAspect.Stretch)]
8 public Sprite ItemIcon { get; }
9}

IconColor

Summary

Tints the drawn graphic a color.

Also see: AssetIconAttribute, AssetIconsStyle.

Definition

public static class IconColor;

Example

The AssetIconAttribute accepts a string "color" for styling.

IconColor contains example strings that can be used when tinting in the AssetIconAttribute.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(aspect: IconAspect.Stretch)]
8 public Sprite ItemIcon { get; }
9}

Static Fields

Field Description

White

No tinting. This field has a constant value of "#ffffff".

Black

Tints the drawn graphic black. This field has a constant value of "#000000".

Gray

Tints the drawn graphic gray. This field has a constant value of "#888888".

Blue

Tints the drawn graphic blue. This field has a constant value of "#446fc2".

Cyan

Tints the drawn graphic cyan. This field has a constant value of "#4c88ad".

Green

Tints the drawn graphic green. This field has a constant value of "#4cad4f".

Yellow

Tints the drawn graphic yellow. This field has a constant value of "#e3d96b".

Orange

Tints the drawn graphic orange. This field has a constant value of "#de9a47".

Red

Tints the drawn graphic red. This field has a constant value of "#de5147".

Purple

Tints the drawn graphic purple. This field has a constant value of "#8b47de".

Magenta

Tints the drawn graphic magenta. This field has a constant value of "#bd48bb".

IconColor.White

Summary

No tinting.

Definition

public static string White;

Remarks

This is the default value for the styling of AssetIconAttribute.

IconColor.Black

Summary

Tints the drawn graphic black.

Definition

public static string Black;

IconColor.Gray

Summary

Tints the drawn graphic gray.

Definition

public static string Gray;

IconColor.Blue

Summary

Tints the drawn graphic blue.

Definition

public static string Blue;

IconColor.Cyan

Summary

Tints the drawn graphic cyan.

Definition

public static string Cyan;

IconColor.Green

Summary

Tints the drawn graphic green.

Definition

public static string Green;

IconColor.Yellow

Summary

Tints the drawn graphic yellow.

Definition

public static string Yellow;

IconColor.Orange

Summary

Tints the drawn graphic orange.

Definition

public static string Orange;

IconColor.Red

Summary

Tints the drawn graphic red.

Definition

public static string Red;

IconColor.Purple

Summary

Tints the drawn graphic purple.

Definition

public static string Purple;

IconColor.Magenta

Summary

Tints the drawn graphic magenta.

Definition

public static string Magenta;

IconProjection

Summary

An enum that represents camera projections when rendering Prefabs.

Also see: AssetIconAttribute, AssetIconsStyle.

Definition

public enum IconProjection;

Example

The AssetIconAttribute accepts an IconProjection for styling.

IconColor accepts a string "color" for styling.

Below is an example of the IconAspect being to force graphics to stretch across the icon area.

1using AssetIcons;
2using UnityEngine;
3
4[CreateAssetMenu(menuName = "Item")]
5public class Item : ScriptableObject
6{
7 [AssetIcon(projection: IconProjection.Orthographic)]
8 public GameObject ItemIcon { get; }
9}

Enum Values

Field Description

Perspective

Represents a perspective camera projection. This enum has a value of 0.

Orthographic

Represents an orthographic camera projection. This enum has a value of 1.

IconProjection.Perspective

Summary

Represents a perspective camera projection.

Also see: Orthographic.

Definition

IconProjection.Perspective;

Remarks

This is the default value for the styling of AssetIconAttribute.

IconProjection.Orthographic

Summary

Represents an orthographic camera projection.

Also see: Perspective.

Definition

IconProjection.Orthographic;

ProductInformation

Summary

Provides global access to standard information about AssetIcons.

Definition

public static class ProductInformation;

Static Fields

Field Description

Name

The current version of this asset. This field has a constant value of "AssetIcons".

Version

The current version of this asset. This field has a constant value of "2.1.0".

Description

A brief description of this asset. This field has a constant value of "Extension for Unity that draws custom icons inside Unity.".

Author

The author of this asset. This field has a constant value of "Anthony Marmont".

Copyright

Copyright notice for this asset. This field has a constant value of "AssetIcons © 2019 Anthony Marmont".

StorePageUrl

A link to the store for this product. This field has a constant value of "https://assetstore.unity.com/packages/slug/100547".

GitHubUrl

A link to the repository for this product. This field has a constant value of "https://github.com/Fydar/AssetIcons".

IssueTracker

A link to the issue tracker for this product. This field has a constant value of "https://github.com/Fydar/AssetIcons/issues".

ProductInformation.Name

Summary

The current version of this asset.

Also see: Version, Description.

Definition

public static string Name;

ProductInformation.Version

Summary

The current version of this asset.

Definition

public static string Version;

ProductInformation.Description

Summary

A brief description of this asset.

Also see: Name.

Definition

public static string Description;

ProductInformation.Author

Summary

The author of this asset.

Definition

public static string Author;

ProductInformation.StorePageUrl

Summary

A link to the store for this product.

Definition

public static string StorePageUrl;

ProductInformation.GitHubUrl

Summary

A link to the repository for this product.

Definition

public static string GitHubUrl;

ProductInformation.IssueTracker

Summary

A link to the issue tracker for this product.

Definition

public static string IssueTracker;

AssetIconsStyle

Summary

A model that represents the styles defined in the AssetIconAttribute constructor.

Also see: AssetIconAttribute.

Definition

public sealed class AssetIconsStyle;

Instance Constructors

Constructors

Default constructor for AssetIconsStyle.

new AssetIconsStyle()

Instance Properties

Property Description

Width

An expression that's evaluated to determine the width of the icon.

Height

An expression that's evaluated to determine the height of the icon.

X

An expression that's evaluated to determine a horizontal offset of the icon.

Y

An expression that's evaluated to determine a vertical offset of the icon.

MaxSize

A value used to determine the max size of the icon.

Anchor

An anchor that all difference in scale is orientated around.

Aspect

A value used to determine the aspect of the icon.

Display

An expression that's evaluated to whether the icon should be displayed.

Tint

A tint to apply to the icon.

Layer

A value used to determine the layer of the icon.

FontStyle

A font style to use on all rendered text.

TextAnchor

An anchor for all rendered text.

Projection

A camera projection for all rendered Prefabs.

AssetIconsStyle.Width

Summary

An expression that's evaluated to determine the width of the icon.

Also see: Height, X, Y, Display.

Definition

public string Width { get; set; }

AssetIconsStyle.Height

Summary

An expression that's evaluated to determine the height of the icon.

Also see: Width, X, Y, Display.

Definition

public string Height { get; set; }

AssetIconsStyle.X

Summary

An expression that's evaluated to determine a horizontal offset of the icon.

Also see: Width, Height, Y.

Definition

public string X { get; set; }

AssetIconsStyle.Y

Summary

An expression that's evaluated to determine a vertical offset of the icon.

Also see: Width, Height, X.

Definition

public string Y { get; set; }

AssetIconsStyle.MaxSize

Summary

A value used to determine the max size of the icon.

Definition

public int MaxSize { get; set; }

Remarks

100% Width will have a width less than or equal to MaxSize.

AssetIconsStyle.Anchor

Summary

An anchor that all difference in scale is orientated around.

Also see: Width, Height.

Definition

public IconAnchor Anchor { get; set; }

AssetIconsStyle.Aspect

Summary

A value used to determine the aspect of the icon.

Definition

public IconAspect Aspect { get; set; }

AssetIconsStyle.Display

Summary

An expression that's evaluated to whether the icon should be displayed.

Also see: Width, Height.

Definition

public string Display { get; set; }

AssetIconsStyle.Tint

Summary

A tint to apply to the icon.

Also see: IconColor.

Definition

public string Tint { get; set; }

AssetIconsStyle.Layer

Summary

A value used to determine the layer of the icon.

Definition

public int Layer { get; set; }

AssetIconsStyle.FontStyle

Summary

A font style to use on all rendered text.

Also see: TextAnchor.

Definition

public FontStyle FontStyle { get; set; }

AssetIconsStyle.TextAnchor

Summary

An anchor for all rendered text.

Also see: FontStyle.

Definition

public IconAnchor TextAnchor { get; set; }

AssetIconsStyle.Projection

Summary

A camera projection for all rendered Prefabs.

Definition

public IconProjection Projection { get; set; }

Prop

Summary

A sample ScriptableObject that draws a Sprite icon and a Texture2D background.

Also see: VoxelItem.

Definition

public sealed class Prop : ScriptableObject;

Instance Fields

Field Description

Icon

An icon to render the for this ScriptableObject.

Border

An icon to render the for this ScriptableObject's background.

Prop.Icon

Summary

An icon to render the for this ScriptableObject.

Definition

[AssetIcon] [FormerlySerializedAs] public Sprite Icon;

Prop.Border

Summary

An icon to render the for this ScriptableObject's background.

Definition

[AssetIcon] [FormerlySerializedAs] public Texture2D Border;

VoxelItem

Summary

A sample ScriptableObject that draws prefab with a background.

Also see: Prop.

Definition

public sealed class VoxelItem : ScriptableObject;

Instance Fields

Field Description

Icon

A prefab to draw in the center of the icon.

Background

A whole-icon background to draw on the icon.

ItemColor

A small tag to draw in the bottom-right of their icon.

VoxelItem.Icon

Summary

A prefab to draw in the center of the icon.

Definition

[AssetIcon] public GameObject Icon;

VoxelItem.Background

Summary

A whole-icon background to draw on the icon.

Definition

[AssetIcon] public Sprite Background;

VoxelItem.ItemColor

Summary

A small tag to draw in the bottom-right of their icon.

Definition

[AssetIcon] public Color ItemColor;

AssetIconsCameraSetup

Summary

A camera setup used in AssetIconsRenderer to render a Prefab.

Also see: AssetIconsRenderer, AssetIconsRenderCache.

Definition

[Serializable] public struct AssetIconsCameraSetup : IEquatable<AssetIconsCameraSetup>;

Instance Properties

Property Description

TransparentBackground

Indicates whether the background should be rendered as transparent.

PreviewDirection

The vector direction to render a Prefab from.

Padding

Padding around the edges of a rendered Prefab.

BackgroundColor

The background color of the rendered graphic.

Orthographic

Indicates whether projection should be orthographic.

Instance Methods

Method Description

ApplyToCamera

Applies this AssetIconsCameraSetup to a Unity Camera.

Equals

Evaluates whether this AssetIconsCameraSetup is equal to an object.

GetHashCode

Returns a unique hash for this of AssetIconsCameraSetup.

Static Properties

Property Description

Default

A set of default settings to render a Prefab with.

Operators

Operator Description

==

Evaluates whether a AssetIconsCameraSetup is equal to another AssetIconsCameraSetup.

!=

Evaluates whether a AssetIconsCameraSetup is not equal to another AssetIconsCameraSetup.

AssetIconsCameraSetup.TransparentBackground

Summary

Indicates whether the background should be rendered as transparent.

Definition

public bool TransparentBackground { get; set; }

AssetIconsCameraSetup.PreviewDirection

Summary

The vector direction to render a Prefab from.

Definition

public Vector3 PreviewDirection { get; set; }

AssetIconsCameraSetup.Padding

Summary

Padding around the edges of a rendered Prefab.

Definition

public float Padding { get; set; }

AssetIconsCameraSetup.BackgroundColor

Summary

The background color of the rendered graphic.

Definition

public Color BackgroundColor { get; set; }

AssetIconsCameraSetup.Orthographic

Summary

Indicates whether projection should be orthographic.

Definition

public bool Orthographic { get; set; }

AssetIconsCameraSetup.ApplyToCamera

Summary

Applies this AssetIconsCameraSetup to a Unity Camera.

Definition

public void ApplyToCamera(
Camera camera
)

AssetIconsCameraSetup.Equals

Summary

Evaluates whether this AssetIconsCameraSetup is equal to an object.

Definition

public virtual bool Equals(
object obj
)

AssetIconsCameraSetup.GetHashCode

Summary

Returns a unique hash for this of AssetIconsCameraSetup.

Definition

public virtual int GetHashCode()

AssetIconsCameraSetup.Default

Summary

A set of default settings to render a Prefab with.

Definition

public static AssetIconsCameraSetup Default { get; }

AssetIconsCameraSetup.==

Summary

Evaluates whether a AssetIconsCameraSetup is equal to another AssetIconsCameraSetup.

Definition

public static bool operator ==(
AssetIconsCameraSetup left,
AssetIconsCameraSetup right
)

AssetIconsCameraSetup.!=

Summary

Evaluates whether a AssetIconsCameraSetup is not equal to another AssetIconsCameraSetup.

Definition

public static bool operator !=(
AssetIconsCameraSetup left,
AssetIconsCameraSetup right
)

AssetIconsCompiledStyle

Summary

A formatted representation of the AssetIconsStyle for drawing graphics in the AssetIconsGUI.

Also see: AssetIconsStyle, AssetIconsGUI.

Definition

public sealed class AssetIconsCompiledStyle;

Instance Constructors

Constructors

Constructs a new instance of the AssetIconsCompiledStyle from a AssetIconsStyle.

new AssetIconsCompiledStyle(
AssetIconsStyle style
)

Instance Properties

Property Description

MaxSize

A value used to determine the max size of the icon.

Aspect

A value used to determine the aspect of the icon.

Anchor

An anchor that all difference in scale is orientated around.

Tint

A tint to apply to the icon.

Layer

A value used to determine the layer of the icon.

FontStyle

A font style to use on all rendered text.

TextAnchor

An anchor for all rendered text.

Projection

A camera projection for all rendered Prefabs.

Instance Methods

Method Description

Filter

Applies this AssetIconsCompiledStyle to a Rect.

Static Properties

Property Description

Default

A AssetIconsCompiledStyle for the default constructor of AssetIconsStyle.

AssetIconsCompiledStyle.MaxSize

Summary

A value used to determine the max size of the icon.

Definition

public int MaxSize { get; set; }

AssetIconsCompiledStyle.Aspect

Summary

A value used to determine the aspect of the icon.

Definition

public IconAspect Aspect { get; set; }

AssetIconsCompiledStyle.Anchor

Summary

An anchor that all difference in scale is orientated around.

Definition

public Vector2 Anchor { get; set; }

AssetIconsCompiledStyle.Tint

Summary

A tint to apply to the icon.

Definition

public Color Tint { get; set; }

AssetIconsCompiledStyle.Layer

Summary

A value used to determine the layer of the icon.

Definition

public int Layer { get; set; }

AssetIconsCompiledStyle.FontStyle

Summary

A font style to use on all rendered text.

Definition

public FontStyle FontStyle { get; set; }

AssetIconsCompiledStyle.TextAnchor

Summary

An anchor for all rendered text.

Definition

public TextAnchor TextAnchor { get; set; }

AssetIconsCompiledStyle.Projection

Summary

A camera projection for all rendered Prefabs.

Definition

public IconProjection Projection { get; set; }

AssetIconsCompiledStyle.Filter

Summary

Applies this AssetIconsCompiledStyle to a Rect.

Definition

public Rect Filter(
Rect rect,
out bool display
)

AssetIconsCompiledStyle.Default

Summary

A AssetIconsCompiledStyle for the default constructor of AssetIconsStyle.

Also see: AssetIconsStyle.

Definition

public static AssetIconsCompiledStyle Default { get; }

AssetIconsGUI

Summary

Handles the drawing, sizing and tinting of the assets.

Also see: AssetIconsCompiledStyle.

Definition

public static class AssetIconsGUI;

Static Properties

Property Description

BackgroundColor

A Color that imitates Unity's project window background.

Static Methods

Method Description

DrawBackground

Draws an empty background using BackgroundColor to hide Unity's original icon.

DrawColor

Draw a flat Color.

DrawSprite

Draws a sprite graphic at a specified Rect.

DrawText

Draws text at a specified Rect.

DrawTexture

Draws a texture graphic at a specified Rect.

DrawTexWithCoords

Draws a portion of a texture at a specified Rect.

DrawTexWithUVCoords

Draws a portion of a texture at a specified Rect.

AssetIconsGUI.BackgroundColor

Summary

A Color that imitates Unity's project window background.

Definition

public static Color BackgroundColor { get; }

Remarks

This Color is used for masking the icon that Unity draws.

This changes with Untiy's pro-skin across differnet versions of Unity.

AssetIconsGUI.DrawBackground

Summary

Draws an empty background using BackgroundColor to hide Unity's original icon.

Definition

public static void DrawBackground(
Rect rect
)

Remarks

This Color is used for masking the icon that Unity draws.

This changes with Untiy's pro-skin across differnet versions of Unity.

AssetIconsGUI.DrawColor

Summary

Draw a flat Color.

Definition

public static void DrawColor(
Rect rect,
Color color,
AssetIconsCompiledStyle style = null,
bool selected = false
)

Example

Below is an example of drawing a flat colour in an editor window.

1using AssetIcons.Editors;
2using UnityEditor;
3using UnityEngine;
4
5public class DemoWindow : EditorWindow
6{
7 [MenuItem("AssetIcons/Demo Window")]
8 private static void Init()
9 {
10 var window = GetWindow(typeof(DemoWindow), false, "Demo Window");
11 window.Show();
12 }
13
14 private void OnGUI()
15 {
16 var rect = GUILayoutUtility.GetRect(20.0f, 20.0f);
17
18 AssetIconsGUI.DrawColor(rect, Color.red);
19 }
20}

AssetIconsGUI.DrawSprite

Summary

Draws a sprite graphic at a specified Rect.

Definition

public static void DrawSprite(
Rect rect,
Sprite sprite,
AssetIconsCompiledStyle style = null,
bool selected = false
)

Example

Below is an example of drawing a sprite in an editor window.

1using AssetIcons.Editors;
2using UnityEditor;
3using UnityEngine;
4
5public class DemoWindow : EditorWindow
6{
7 private Sprite spriteToDraw;
8
9 [MenuItem("AssetIcons/Demo Window")]
10 private static void Init()
11 {
12 var window = GetWindow(typeof(DemoWindow), false, "Demo Window");
13 window.Show();
14 }
15
16 private void OnGUI()
17 {
18 spriteToDraw = EditorGUILayout.ObjectField(spriteToDraw, typeof(Sprite), false);
19
20 var rect = GUILayoutUtility.GetRect(20.0f, 20.0f);
21
22 AssetIconsGUI.DrawSprite(rect, spriteToDraw);
23 }
24}

Remarks

This implementation draws a Texture2D and crops the boundaries. This may result in sprites that are tightly packed to draw artifacts.

AssetIconsGUI.DrawText

Summary

Draws text at a specified Rect.

Definition

public static void DrawText(
Rect rect,
string text,
AssetIconsCompiledStyle style = null,
bool selected = false
)

Example

Below is an example of drawing a string in an editor window.

1using AssetIcons.Editors;
2using UnityEditor;
3using UnityEngine;
4
5public class DemoWindow : EditorWindow
6{
7 [MenuItem("AssetIcons/Demo Window")]
8 private static void Init()
9 {
10 var window = GetWindow(typeof(DemoWindow), false, "Demo Window");
11 window.Show();
12 }
13
14 private void OnGUI()
15 {
16 var rect = GUILayoutUtility.GetRect(20.0f, 20.0f);
17
18 AssetIconsGUI.DrawText(rect, "Example");
19 }
20}

AssetIconsGUI.DrawTexture

Summary

Draws a texture graphic at a specified Rect.

Definition

public static void DrawTexture(
Rect rect,
Texture texture,
AssetIconsCompiledStyle style = null,
bool selected = false
)

Example

Below is an example of drawing a sprite in an editor window.

1using AssetIcons.Editors;
2using UnityEditor;
3using UnityEngine;
4
5public class DemoWindow : EditorWindow
6{
7 private Texture textureToDraw;
8
9 [MenuItem("AssetIcons/Demo Window")]
10 private static void Init()
11 {
12 var window = GetWindow(typeof(DemoWindow), false, "Demo Window");
13 window.Show();
14 }
15
16 private void OnGUI()
17 {
18 textureToDraw = EditorGUILayout.ObjectField(spriteToDraw, typeof(Texture), false);
19
20 var rect = GUILayoutUtility.GetRect(20.0f, 20.0f);
21
22 AssetIconsGUI.DrawSprite(rect, textureToDraw);
23 }
24}

AssetIconsGUI.DrawTexWithCoords

Summary

Draws a portion of a texture at a specified Rect.

Definition

public static void DrawTexWithCoords(
Rect rect,
Texture texture,
Rect textureRect,
AssetIconsCompiledStyle style = null,
bool selected = false
)

Example

Below is an example of drawing a sprite in an editor window.

1using AssetIcons.Editors;
2using UnityEditor;
3using UnityEngine;
4
5public class DemoWindow : EditorWindow
6{
7 private Texture textureToDraw;
8
9 [MenuItem("AssetIcons/Demo Window")]
10 private static void Init()
11 {
12 var window = GetWindow(typeof(DemoWindow), false, "Demo Window");
13 window.Show();
14 }
15
16 private void OnGUI()
17 {
18 textureToDraw = EditorGUILayout.ObjectField(spriteToDraw, typeof(Texture), false);
19
20 var rect = GUILayoutUtility.GetRect(20.0f, 20.0f);
21
22 AssetIconsGUI.DrawTexWithCoords(rect, textureToDraw, new Rect(8.0f, 8.0f, 32.0f, 32.0f));
23 }
24}

AssetIconsGUI.DrawTexWithUVCoords

Summary

Draws a portion of a texture at a specified Rect.

Definition

public static void DrawTexWithUVCoords(
Rect rect,
Texture texture,
Rect uvCoords,
AssetIconsCompiledStyle style = null,
bool selected = false
)

Example

Below is an example of drawing a sprite in an editor window.

1using AssetIcons.Editors;
2using UnityEditor;
3using UnityEngine;
4
5public class DemoWindow : EditorWindow
6{
7 private Texture textureToDraw;
8
9 [MenuItem("AssetIcons/Demo Window")]
10 private static void Init()
11 {
12 var window = GetWindow(typeof(DemoWindow), false, "Demo Window");
13 window.Show();
14 }
15
16 private void OnGUI()
17 {
18 textureToDraw = EditorGUILayout.ObjectField(spriteToDraw, typeof(Texture), false);
19
20 var rect = GUILayoutUtility.GetRect(20.0f, 20.0f);
21
22 AssetIconsGUI.DrawTexWithUVCoords(rect, textureToDraw, new Rect(0.25, 0.25f, 0.5f, 0.5f));
23 }
24}

AssetIconsGUIUtility

Summary

A collection of utility methods for drawing graphics with AssetIcons.

Definition

public static class AssetIconsGUIUtility;

Static Methods

Method Description

AreaToIconRect

Remaps a Rect to conform with Unity's UI control positions.

AssetIconsGUIUtility.AreaToIconRect

Summary

Remaps a Rect to conform with Unity's UI control positions.

Definition

public static Rect AreaToIconRect(
Rect rect,
float maxSize = 64
)

AssetIconsProjectHooks

Summary

AssetIcons uses this to manage the rendering callbacks.

Definition

public static class AssetIconsProjectHooks;

Static Events

Event Description

OnDrawIcon

The callback that AssetIcons uses to draw draw icons.

DrawAssetIconCallback

Summary

Delgate used by AssetIcons to draw an icon.

Definition

public delegate void DrawAssetIconCallback(
string guid,
Rect area
)

AssetIconsProjectHooks.OnDrawIcon

Summary

The callback that AssetIcons uses to draw draw icons.

Definition

public static event DrawAssetIconCallback OnDrawIcon;

AssetIconsRenderCache

Summary

Cache renders of the models that we would like to render.

Also see: AssetIconsRenderer, AssetIconsCameraSetup.

Definition

public sealed class AssetIconsRenderCache : AssetModificationProcessor;

Static Methods

Method Description

GetTexture

Retrieves a Texture2D from the cache for a GameObject using a AssetIconsCameraSetup.

ClearCache

Clears all rendered textures from this cache.

AssetIconsRenderCache.GetTexture

Summary

Retrieves a Texture2D from the cache for a GameObject using a AssetIconsCameraSetup.

Definition

public static Texture2D GetTexture(
AssetIconsCameraSetup cameraSetup,
GameObject target
)

AssetIconsRenderCache.ClearCache

Summary

Clears all rendered textures from this cache.

Definition

public static void ClearCache()

AssetIconsRenderer

Summary

Used by AssetIcons to render Prefabs to a Texture2D.

Also see: AssetIconsCameraSetup.

Definition

public static class AssetIconsRenderer;

Static Methods

Method Description

RenderModel

Creates a preview Texture2D of a model.

AssetIconsRenderer.RenderModel

Summary

Creates a preview Texture2D of a model.

Definition

public static Texture2D RenderModel(
GameObject model,
AssetIconsCameraSetup camera,
int width = 64,
int height = 64
)

AssetIconsPreferences

Summary

Stores AssetIcons preferences information in EditorPrefs.

Also see: AssetIconsPreferencesPreset.

Definition

public static class AssetIconsPreferences;

Example

You can interact with AssetIcons preferences via an editor scripting API.

1using AssetIcons.Editors.Preferences;
2using UnityEditor;
3
4public class DemoWindow : EditorWindow
5{
6 [MenuItem("AssetIcons/Demo Window")]
7 private static void Init()
8 {
9 var window = GetWindow(typeof(DemoWindow), false, "Demo Window");
10 window.Show();
11 }
12
13 private void OnGUI()
14 {
15 AssetIconsPreferences.Enabled.Value = EditorGUILayout.Toggle("AssetIcons Enabled", AssetIconsPreferences.Enabled.Value);
16 }
17}

Static Fields

Field Description

EditorPrefsKey

The EditorPrefs key used to store the current users preferences. This field has a constant value of "AssetIcons_Preferences".

Static Properties

Property Description

CurrentPreferences

The current set of preferences used by AssetIcons.

DrawGUIStyles

A shorthand for CurrentPreferences.DrawGUIStyles.Enables previewing of Unity GUIStyle assets.

Enabled

A shorthand for CurrentPreferences.Enabled.Controls whether AssetIcons should be enabled or disabled.

PrefabResolution

A shorthand for CurrentPreferences.PrefabResolution.Allows for adjusting the resolution AssetIcons will render Prefabs with.

SelectionTint

A shorthand for CurrentPreferences.SelectionTint.Controls how strong of a tint is applied to AssetIcons rendered graphics when selected.

TypeIcons

A shorthand for CurrentPreferences.TypeIcons.A collection of Graphics associated with file extensions that AssetIcons uses to render custom file icons.

HideReviewDialog

A shorthand for CurrentPreferences.HideReviewDialog.Controls whether the review dialog should be shown.

Remarks

These preferences are effective on a single machine and in a single Unity project. Changing to another project with AssetIcons installed will not preserve these saved preferences.

AssetIconsPreferences.EditorPrefsKey

Summary

The EditorPrefs key used to store the current users preferences.

Definition

public static string EditorPrefsKey;

AssetIconsPreferences.CurrentPreferences

Summary

The current set of preferences used by AssetIcons.

Definition

public static AssetIconsPreferencesPreset CurrentPreferences { get; }

Example

You can interact with AssetIcons preferences via an editor scripting API.

1using AssetIcons.Editors.Preferences;
2using UnityEditor;
3
4public class DemoWindow : EditorWindow
5{
6 [MenuItem("AssetIcons/Demo Window")]
7 private static void Init()
8 {
9 var window = GetWindow(typeof(DemoWindow), false, "Demo Window");
10 window.Show();
11 }
12
13 private void OnGUI()
14 {
15 var preferences = AssetIconsPreferences.CurrentPreferences;
16
17 preferences.Enabled.Value = EditorGUILayout.Toggle("AssetIcons Enabled", preferences.Enabled.Value);
18 }
19}

AssetIconsPreferences.DrawGUIStyles

Summary

A shorthand for CurrentPreferences.DrawGUIStyles.

Enables previewing of Unity GUIStyle assets.

Definition

public static BoolEventField DrawGUIStyles { get; }

AssetIconsPreferences.Enabled

Summary

A shorthand for CurrentPreferences.Enabled.

Controls whether AssetIcons should be enabled or disabled.

Definition

public static BoolEventField Enabled { get; }

AssetIconsPreferences.PrefabResolution

Summary

A shorthand for CurrentPreferences.PrefabResolution.

Allows for adjusting the resolution AssetIcons will render Prefabs with.

Definition

public static IntEventField PrefabResolution { get; }

Remarks

If you are struggling with performance with a large amount of rendered assets, you could try adjusting this to boost performance.

AssetIconsPreferences.SelectionTint

Summary

A shorthand for CurrentPreferences.SelectionTint.

Controls how strong of a tint is applied to AssetIcons rendered graphics when selected.

Definition

public static ColorTintEventField SelectionTint { get; }

AssetIconsPreferences.TypeIcons

Summary

A shorthand for CurrentPreferences.TypeIcons.

A collection of Graphics associated with file extensions that AssetIcons uses to render custom file icons.

Definition

public static IconMapping TypeIcons { get; }

AssetIconsPreferences.HideReviewDialog

Summary

A shorthand for CurrentPreferences.HideReviewDialog.

Controls whether the review dialog should be shown.

Definition

public static BoolEventField HideReviewDialog { get; }

AssetIconsPreferencesPreset

Summary

Represents user preferences in a serializable format.

Also see: AssetIconsPreferences.

Definition

public sealed class AssetIconsPreferencesPreset : ScriptableObject;

Instance Properties

Property Description

Enabled

Controls whether AssetIcons should be enabled or disabled.

DrawGUIStyles

Enables previewing of Unity GUIStyle assets.

PrefabResolution

Allows for adjusting the resolution AssetIcons will render Prefabs with.

SelectionTint

Controls how strong of a tint is applied to AssetIcons rendered graphics when selected.

TypeIcons

A collection of graphics associated with file extensions that AssetIcons uses to render custom file icons.

HideReviewDialog

Controls whether the review dialog should be shown.

AssetIconsPreferencesPreset.Enabled

Summary

Controls whether AssetIcons should be enabled or disabled.

Definition

public BoolEventField Enabled { get; }

AssetIconsPreferencesPreset.DrawGUIStyles

Summary

Enables previewing of Unity GUIStyle assets.

Definition

public BoolEventField DrawGUIStyles { get; }

AssetIconsPreferencesPreset.PrefabResolution

Summary

Allows for adjusting the resolution AssetIcons will render Prefabs with.

Definition

public IntEventField PrefabResolution { get; }

Remarks

If you are struggling with performance with a large amount of rendered assets, you could try adjusting this to boost performance.

AssetIconsPreferencesPreset.SelectionTint

Summary

Controls how strong of a tint is applied to AssetIcons rendered graphics when selected.

Definition

public ColorTintEventField SelectionTint { get; }

AssetIconsPreferencesPreset.TypeIcons

Summary

A collection of graphics associated with file extensions that AssetIcons uses to render custom file icons.

Definition

public IconMapping TypeIcons { get; }

AssetIconsPreferencesPreset.HideReviewDialog

Summary

Controls whether the review dialog should be shown.

Definition

public BoolEventField HideReviewDialog { get; set; }

BoolEventField

Summary

A concrete implementation of the EventField for bool.

Also see: IntEventField, ColorTintEventField.

Definition

[Serializable] public sealed class BoolEventField : EventField<bool>, ISerializationCallbackReceiver;

Instance Constructors

Constructors

Constructs a new instance of this BoolEventField.

new BoolEventField()

Constructs a new instance of this with a default value.

new BoolEventField(
bool defaultValue
)

Remarks

This is nessesary for Unity to be able to serialize generic types.

ColorTint

Summary

A data type used to tint graphics.

Also see: ColorTintEventField.

Definition

[Serializable] public struct ColorTint : IEquatable<ColorTint>;

Instance Constructors

Constructors

Constructs a new instance of the ColorTint.

new ColorTint(
float tintStrength
)

Instance Properties

Property Description

TintColor

A color to tint rendered graphics.

TintStrength

The strength of the tint.

Instance Methods

Method Description

Apply

Applies the tint to a source color.

Equals

Evaluates whether this ColorTint is equal to an object.

GetHashCode

Returns a unique hash for this of ColorTint.

Operators

Operator Description

==

Evaluates whether a ColorTint is equal to another ColorTint.

!=

Evaluates whether a ColorTint is not equal to another ColorTint.

ColorTint.TintColor

Summary

A color to tint rendered graphics.

Definition

public Color TintColor { get; }

ColorTint.TintStrength

Summary

The strength of the tint.

Definition

public float TintStrength { get; }

ColorTint.Apply

Summary

Applies the tint to a source color.

Definition

public Color Apply(
Color source
)

ColorTint.Equals

Summary

Evaluates whether this ColorTint is equal to an object.

Definition

public virtual bool Equals(
object obj
)

ColorTint.GetHashCode

Summary

Returns a unique hash for this of ColorTint.

Definition

public virtual int GetHashCode()

ColorTint.==

Summary

Evaluates whether a ColorTint is equal to another ColorTint.

Definition

public static bool operator ==(
ColorTint left,
ColorTint right
)

ColorTint.!=

Summary

Evaluates whether a ColorTint is not equal to another ColorTint.

Definition

public static bool operator !=(
ColorTint left,
ColorTint right
)

ColorTintEventField

Summary

A concrete implementation of the EventField for ColorTint.

Also see: BoolEventField, IntEventField, ColorTint.

Definition

[Serializable] public sealed class ColorTintEventField : EventField<ColorTint>, ISerializationCallbackReceiver;

Instance Constructors

Constructors

Constructs a new instance of this ColorTintEventField.

new ColorTintEventField()

Constructs a new instance of this with a default value.

new ColorTintEventField(
ColorTint defaultValue
)

Remarks

This is nessesary for Unity to be able to serialize generic types.

EventField

Summary

A base-class for the generic wrapper object that fires events whenever its value changes.

Definition

public abstract class EventField;

Instance Events

Event Description

OnChanged

Event that is fired whenever the value of this EventField changes.

EventField.OnChanged

Summary

Event that is fired whenever the value of this EventField changes.

Definition

public event Action OnChanged;

EventField<T>

Summary

A generic wrapper object that fires events whenever its value changes.

Also see: BoolEventField, IntEventField.

Definition

public class EventField<T> : EventField, ISerializationCallbackReceiver;

Instance Constructors

Constructors

Constructs a new instance of this EventField.

new EventField()

Constructs a new instance of this EventField with a default value.

new EventField(
T defaultValue
)

Instance Properties

Property Description

Value

The value that this wrapper currently represents.

Instance Methods

Method Description

OnAfterDeserialize

Implements the Unity ISerializationCallbackReceiver interface.

OnBeforeSerialize

Implements the Unity ISerializationCallbackReceiver interface.

EventField.Value

Summary

The value that this wrapper currently represents.

Definition

public T Value { get; set; }

EventField.OnAfterDeserialize

Summary

Implements the Unity ISerializationCallbackReceiver interface.

Definition

public virtual void OnAfterDeserialize()

EventField.OnBeforeSerialize

Summary

Implements the Unity ISerializationCallbackReceiver interface.

Definition

public virtual void OnBeforeSerialize()

IconMapping

Summary

Provides a serializable dictionary for mapping an extension type to an PreferencesAssetReference.

Also see: AssetIconsPreferencesPreset, PreferencesAssetReference.

Definition

[Serializable] public sealed class IconMapping : ISerializationCallbackReceiver;

Instance Events

Event Description

OnChanged

An event that fires whenever the content of the table changes.

Instance Methods

Method Description

Add

Add a key and a value to the IconMapping.

Clear

Clear all values from the IconMapping.

Remove

Removes an element from the table using a key.

IconMapping.Add

Summary

Add a key and a value to the IconMapping.

Definition

public void Add(
string key,
PreferencesAssetReference value
)

IconMapping.Clear

Summary

Clear all values from the IconMapping.

Definition

public void Clear()

IconMapping.Remove

Summary

Removes an element from the table using a key.

Definition

public bool Remove(
string key
)

IconMapping.OnChanged

Summary

An event that fires whenever the content of the table changes.

Definition

public event Action OnChanged;

IntEventField

Summary

A concrete implementation of the EventField for int.

Also see: BoolEventField, ColorTintEventField.

Definition

[Serializable] public sealed class IntEventField : EventField<int>, ISerializationCallbackReceiver;

Instance Constructors

Constructors

Constructs a new instance of this IntEventField.

new IntEventField()

Constructs a new instance of this with a default value.

new IntEventField(
int defaultValue
)

Remarks

This is nessesary for Unity to be able to serialize generic types.

PreferencesAssetReference

Summary

Used to reference assets inside the Unity project inside the editor.

Definition

[Serializable] public sealed class PreferencesAssetReference;

Instance Properties

Property Description

GraphicDrawer

A IGraphicDrawer for the asset referenced by this PreferencesAssetReference.

AssetPath

A path, relative to the Unity project root, used to reference the asset.

AssetName

The name of the asset.

ObjectReference

Load or assign assets from the AssetDatabase.

Static Methods

Method Description

GetFromPath

Loads an asset from the AssetDatabase with the specified name.

Remarks

This is used inside the AssetIconsPreferencesPreset to select assets to render an icon.

PreferencesAssetReference.GraphicDrawer

Summary

A IGraphicDrawer for the asset referenced by this PreferencesAssetReference.

Definition

public IGraphicDrawer GraphicDrawer { get; }

PreferencesAssetReference.AssetPath

Summary

A path, relative to the Unity project root, used to reference the asset.

Definition

public string AssetPath { get; set; }

PreferencesAssetReference.AssetName

Summary

The name of the asset.

Definition

public string AssetName { get; set; }

PreferencesAssetReference.ObjectReference

Summary

Load or assign assets from the AssetDatabase.

Definition

public Object ObjectReference { get; set; }

PreferencesAssetReference.GetFromPath

Summary

Loads an asset from the AssetDatabase with the specified name.

Definition

public static Object GetFromPath(
string assetPath,
string assetName
)

IAssetIconPipeline

Summary

Apart of the public API for extending AssetIcons.

Used to add custom IGraphicDrawerFactory to AssetIcons.

Definition

public interface IAssetIconPipeline;

Example

Below is an example of an extension to AssetIcons that draws colored boxes based on a bool value.

1using AssetIcons.Editors;
2using AssetIcons.Editors.Pipeline;
3using System;
4using UnityEngine;
5
6public class BooleanAssetIconsExtension : IAssetIconsExtension
7{
8 public void Initialise(IAssetIconPipeline pipeline)
9 {
10 pipeline.RegisterDrawer(new BooleanGraphicDrawerFactory());
11 }
12}
13
14public class BooleanGraphicDrawerFactory : IGraphicDrawerFactory
15{
16 private class BooleanGraphicDrawer : IGraphicDrawer
17 {
18 private bool hasValue;
19 private bool lastValue;
20
21 public bool CanDraw()
22 {
23 return hasValue;
24 }
25
26 public void Draw(Rect rect, bool selected, AssetIconsCompiledStyle style)
27 {
28 // Transform the rect of the icon in the Project window to the rect of the actual graphic.
29 var drawRect = AssetIconsGUIUtility.AreaToIconRect(rect, style.MaxSize);
30
31 // Using AssetIconsGUI allows us to draw stuff using the user-defined style.
32
33 if (lastValue)
34 {
35 // Draw a green square
36 AssetIconsGUI.DrawColor(drawRect, new Color32(0, 255, 0, 255), style, selected);
37 }
38 else
39 {
40 // Draw a red square
41 AssetIconsGUI.DrawColor(drawRect, new Color32(255, 0, 0, 255), style, selected);
42 }
43 }
44
45 public void SetValue(object value)
46 {
47 if (value != null)
48 {
49 lastValue = (bool)value;
50 hasValue = true;
51 }
52 else
53 {
54 hasValue = false;
55 }
56 }
57 }
58
59 public int Priority
60 {
61 get
62 {
63 // All of AssetIcons' drawers use 100 as a default value.
64 // The higher the priority, the more likely it is it will be used.
65 return 150;
66 }
67 }
68
69 public IGraphicDrawer CreateDrawer()
70 {
71 return new BooleanGraphicDrawer();
72 }
73
74 public bool IsValidFor(Type type)
75 {
76 return type == typeof(bool);
77 }
78}

Instance Methods

Method Description

CreateGraphicDrawer

Create an IGraphicDrawer to draw a graphic of Type.

RegisterDrawer

Registers a new IGraphicDrawerFactory with the IAssetIconPipeline.

IAssetIconPipeline.CreateGraphicDrawer

Summary

Create an IGraphicDrawer to draw a graphic of Type.

Also see: IGraphicDrawerFactory.

Definition

IGraphicDrawer CreateGraphicDrawer(
Type type
)

IAssetIconPipeline.RegisterDrawer

Summary

Registers a new IGraphicDrawerFactory with the IAssetIconPipeline.

Also see: IGraphicDrawerFactory, IGraphicDrawer.

Definition

void RegisterDrawer(
IGraphicDrawerFactory graphicDrawerFactory
)

IAssetIconsExtension

Summary

The interface that allows users to extend AssetIcons with new features.

Also see: IAssetIconPipeline, IGraphicDrawerFactory.

Definition

public interface IAssetIconsExtension;

Example

Below is an example of an extension to AssetIcons that draws colored boxes based on a bool value.

1using AssetIcons.Editors;
2using AssetIcons.Editors.Pipeline;
3using System;
4using UnityEngine;
5
6public class BooleanAssetIconsExtension : IAssetIconsExtension
7{
8 public void Initialise(IAssetIconPipeline pipeline)
9 {
10 pipeline.RegisterDrawer(new BooleanGraphicDrawerFactory());
11 }
12}
13
14public class BooleanGraphicDrawerFactory : IGraphicDrawerFactory
15{
16 private class BooleanGraphicDrawer : IGraphicDrawer
17 {
18 private bool hasValue;
19 private bool lastValue;
20
21 public bool CanDraw()
22 {
23 return hasValue;
24 }
25
26 public void Draw(Rect rect, bool selected, AssetIconsCompiledStyle style)
27 {
28 // Transform the rect of the icon in the Project window to the rect of the actual graphic.
29 var drawRect = AssetIconsGUIUtility.AreaToIconRect(rect, style.MaxSize);
30
31 // Using AssetIconsGUI allows us to draw stuff using the user-defined style.
32
33 if (lastValue)
34 {
35 // Draw a green square
36 AssetIconsGUI.DrawColor(drawRect, new Color32(0, 255, 0, 255), style, selected);
37 }
38 else
39 {
40 // Draw a red square
41 AssetIconsGUI.DrawColor(drawRect, new Color32(255, 0, 0, 255), style, selected);
42 }
43 }
44
45 public void SetValue(object value)
46 {
47 if (value != null)
48 {
49 lastValue = (bool)value;
50 hasValue = true;
51 }
52 else
53 {
54 hasValue = false;
55 }
56 }
57 }
58
59 public int Priority
60 {
61 get
62 {
63 // All of AssetIcons' drawers use 100 as a default value.
64 // The higher the priority, the more likely it is it will be used.
65 return 150;
66 }
67 }
68
69 public IGraphicDrawer CreateDrawer()
70 {
71 return new BooleanGraphicDrawer();
72 }
73
74 public bool IsValidFor(Type type)
75 {
76 return type == typeof(bool);
77 }
78}

Instance Methods

Method Description

Initialise

Called during AssetIcons' startup sequence.

IAssetIconsExtension.Initialise

Summary

Called during AssetIcons' startup sequence.

Also see: IAssetIconsExtension.

Definition

void Initialise(
IAssetIconPipeline pipeline
)

Example

Here is an example of what an entrypoint to an AssetIcons extension looks like.

1using AssetIcons.Editors.Pipeline;
2using UnityEngine;
3
4public class BooleanAssetIconsExtension : IAssetIconsExtension
5{
6 public void Initialise(IAssetIconPipeline pipeline)
7 {
8 Debug.Log("Entrypoint for AssetIcons extensions.");
9 }
10}

IGraphicDrawer

Summary

A drawer for arbitrary objects.

Definition

public interface IGraphicDrawer;

Example

Below is an example of a graphic drawer that draws a colour based on a bool value.

1using AssetIcons.Editors;
2using AssetIcons.Editors.Pipeline;
3using System;
4using UnityEngine;
5
6private class BooleanGraphicDrawer : IGraphicDrawer
7{
8 private bool hasValue;
9 private bool lastValue;
10
11 public bool CanDraw()
12 {
13 return hasValue;
14 }
15
16 public void Draw(Rect rect, bool selected, AssetIconsCompiledStyle style)
17 {
18 // Transform the rect of the icon in the Project window to the rect of the actual graphic.
19 var drawRect = AssetIconsGUIUtility.AreaToIconRect(rect, style.MaxSize);
20
21 // Using AssetIconsGUI allows us to draw stuff using the user-defined style.
22
23 if (lastValue)
24 {
25 // Draw a green square
26 AssetIconsGUI.DrawColor(drawRect, new Color32(0, 255, 0, 255), style, selected);
27 }
28 else
29 {
30 // Draw a red square
31 AssetIconsGUI.DrawColor(drawRect, new Color32(255, 0, 0, 255), style, selected);
32 }
33 }
34
35 public void SetValue(object value)
36 {
37 if (value != null)
38 {
39 lastValue = (bool)value;
40 hasValue = true;
41 }
42 else
43 {
44 hasValue = false;
45 }
46 }
47}

Instance Methods

Method Description

SetValue

Sets the current value of this graphic drawer.

CanDraw

Determines whether this IGraphicDrawer is usable to draw a graphic.

Draw

Renders the last value of this IGraphicDrawer.

IGraphicDrawer.SetValue

Summary

Sets the current value of this graphic drawer.

Definition

void SetValue(
object value
)

IGraphicDrawer.CanDraw

Summary

Determines whether this IGraphicDrawer is usable to draw a graphic.

Definition

bool CanDraw()

IGraphicDrawer.Draw

Summary

Renders the last value of this IGraphicDrawer.

Definition

void Draw(
Rect rect,
bool selected,
AssetIconsCompiledStyle style
)

IGraphicDrawerFactory

Summary

A factory for IGraphicDrawers used to extend AssetIcons with additional support..

Definition

public interface IGraphicDrawerFactory;

Instance Properties

Property Description

Priority

Determines the importance of this IGraphicDrawerFactory.A higher Priority means that this IGraphicDrawerFactory will be used over other IGraphicDrawerFactory.

Instance Methods

Method Description

IsValidFor

Whether this IGraphicDrawerFactory is valid for drawing objects of specified Type.

CreateDrawer

Creates an IGraphicDrawer from this factory.

IGraphicDrawerFactory.Priority

Summary

Determines the importance of this IGraphicDrawerFactory.

A higher Priority means that this IGraphicDrawerFactory will be used over other IGraphicDrawerFactory.

Definition

int Priority { get; }

IGraphicDrawerFactory.IsValidFor

Summary

Whether this IGraphicDrawerFactory is valid for drawing objects of specified Type.

Definition

bool IsValidFor(
Type type
)

IGraphicDrawerFactory.CreateDrawer

Summary

Creates an IGraphicDrawer from this factory.

Definition

IGraphicDrawer CreateDrawer()