Custom ScriptableObject Icons / Thumbnail

http://docs.unity3d.com/ScriptReference/AssetPreview.html

It seems this would be the thing to override to generate a custom thumbnail... is there any way to do this?

Changing the icon for a script derived from ScriptableObject is easy through the project view, but that icon doesn't carry through to any instances of said ScriptableObject in the project view...

Halp. Thanks.

1 Like

I'm not sure if it's possible, but if it is I'd like to know this as well !

Assuming;

public class AudioItem : ScriptableObject { }

Create a folder called "Gizmos"

In it, add a texture - 128x128 works well - named "AudioItem Icon.png".
Yes, it's a normal space between "AudioItem" - name of your class - and "Icon".

15 Likes

It works.

Thanks @LightStriker_1 !

Strictly speaking this is slightly off topic, but of a similar nature.

Another similar trick can be used with EditorWindows to give them Icons in their title bars.

  • Create a folder in the root of your project named "Editor Default Resources"
  • Create a folder within that new folder named "Icons"
  • Add an image called .png (eg: MyWindow.png) (named after window title)

Now your window will have an Icon displayed in the top left of it's titlebar.

3 Likes

this video shows custom preview and icon at end
https://mail.google.com/mail/u/0/#inbox/14721b7894ef8fe2

2 Likes

Err…you posted a link to your gmail inbox.

6 Likes

sorry

2 Likes

Simply select the script asset in the project window, and you can find an Icon texture property when using Inspector in Debug mode.

Even better: Select the script asset, then at the top left of the inspector, click on the icon, then hit "Other...".

10 Likes

That’s not for scriptableobject instances, just for scripts themselves.

4 Likes

Awesome. wasn’t aware of this. However it doesn’t work when you create a subfolder in the Gizmo folder. Not sure if thats needed, but i assume when you import other assets and if they use a Gizmo folder, the system might break.

If you are referring to including the Gizmos Folder Asset in a unitypackage, then this depends on your Unity version. With newer versions of Unity you simply get a warning in the asset importer. With some versions of Unity (e.g. 5.1, 5.2) you get a bunch of ugly warnings/errors in the console. I’ve posted more about this in relation to the official AssetStoreTools here.

If you are referring to the fact that someone might have a class named Tile in their project with a custom icon and another asset package may also have a Tile class, albeit in a different namespace, then yes: one icon would overwrite the other and all Tile assets would share an icon. This entire “system” is very likely extremely legacy and probably hasn’t been looked at in quite a while.

2 Likes

Thanks! That will be a good read and new learning source. I appreciate your input!

1 Like

Anyone know how to make our icons not look pixelated? Mine look great in the Gizmos folder, but crappy when attached to the actual files in another folder in the Project View.

Just a note to the solution that @LightStriker_1 provided: The gizmos folder must be "Assets/Gizmos".

It would be very useful if this wasn't required, and the Gizmos folder could be placed anywhere inside the project... It would make it easier to provide custom icons for ScriptableObjects in asset packages, and this would make it easier to provide more professional looking assets.

Assuming that your icon images are large enough to contain good detail, even when font size is maximized on a retina display (we use 256x256), you should ensure the following settings in the icon files’ Import Settings:

  • Texture Type: GUI (Editor \ Legacy)
  • Filter Mode: Point

I agree that this would be better and easier to support. I should also mention that it doesn’t stop you from including this in your Asset packages (whether distributed directly or through the Asset Store using the Asset Store Tools). It is less than ideal, but it does work.

Actually, tested in 2017.2, assigning a custom icon on the scriptableObject script asset in the inspector will automatically assign the same icon on the asset created from this scriptable object...

3238192--248798--ScriptableObjectsCustomIcons.jpg

5 Likes

I have produced an asset that does exactly this!

I always wanted to do it in my projects so I set aside some time and finally produced the asset :slight_smile:

It allows for Dynamic ScriptableObject icons with a single attribute! If you love ScriptableObjects, then you will love this asset :slight_smile:

All of the above solutions, per script icons and using Gizmos only allows for one icon for every ScriptableObject, but my asset sources the icon from the ScriptableObject’s data.

3251590--250352--Before After 1.png

1 Like

If you want it dynamic you just need to create a CustomEditor for the asset and override the RenderStaticPreview method like I did there (GitHub - raphael-ernaelsten/Texture3DPreview-for-Unity: This package enables interactive previews of Texture3D assets in Unity's Inspector window. You can directly download the Unity package in the Release section (https://github.com/raphael-ernaelsten/Texture3DPreview-for-Unity/releases))

4 Likes

@raphick My asset allows for sprites to be used and rendered directly into the project window, without the need for creating Texture2Ds and caching them in the backend for each sprite. It also is completely independent of editors and is optimized for a lot of assets.

I do find that using the RenderStaticPreview is capable of doing some of the things my asset can do - which is great :smile:

I think that everyone should be able to adopt this into their workflow, it really encourages the use of ScriptableObjects. ^_^

Quick question - I could never get RenderStaticPreview to work - does it work with the Object Selector window?