4

I created a scipt and editor for it. Now I want to assosiate an icon with it like this: enter image description here

How to do such thing? Cant find any documentation on this.

2 Answers 2

10

You can change the icon by selecting the Object in Project view. Then click the icon in the upper left corner in the Inspector. Then select Other.

[Picture Guide] So after you have selected the script, click on the icon marked in red in the picture below:

enter image description here

Look at the picture below for guidance.

enter image description here

5
  • Will this be somehow transferable (alike to coleegs that use same project or to users of asset store when publishing)? Are there other ways of spesifying such data (from code or via some file editing)?
    – Rella
    Aug 16, 2014 at 23:25
  • It is transferable, so who ever gets your asset will have that icon. However, I am not sure how to do it programmatically, but it should be possible.
    – apxcode
    Aug 16, 2014 at 23:30
  • Sadly it appears to be only for entire GameObject - not for individual MonoBehaviour or editor script.
    – Rella
    Aug 17, 2014 at 16:40
  • I don't know what version of Unity3D you are using. For me it works for Editor, MonoBehaviours, and regular C# classes.
    – apxcode
    Aug 18, 2014 at 1:43
  • The problem is that this will automatically also make the GameObject with this component attached on having a Gizmo in the SceneView (see my question). Do you know if there's a way for only having that icon in the ProjectView and the Inspector but not in the SceneView?
    – derHugo
    Mar 13, 2019 at 14:59
4

If you want to assign an icon to a custom script, I believe you can create a gizmo icon for it and place the image at a project location that maps to the namespace of your script. My understanding is for each MonoBehaviour in your assembly, Unity looks for an associated icon with the name "<className> Icon" under the "Gizmos" folder, but the hierarchy must match the namespace.

So if your MonoBehavior is TestClass and its namespace is Company.Project.Foo, you would place the image in your project at "Assets/Gizmos/Company/Project/Foo/" and image name should be "TestClass Icon".

Your script will then have the icon associated with it when viewed in the Inspector, but I don't believe this will cause it to appear in the SceneView. You should use the DrawGizmo attribute on an editor script, if you want to make the icon appear in the SceneView or perform any other custom gizmo drawing.

In the following example screenshots, I have a script called SafeArea with the namespace Greyborn.Library. I placed the "SafeArea Icon.png" at "Assets/Gizmos/Greyborn/Library/", and the icon immediately appeared in the Inspector and Project windows.

Unity Script Gizmo Example 1

I used a PNG. Other image types may be supported, however when I tested with a PSD image, the gizmo wouldn't show up. Be sure to set the Texture Type to "Editor GUI and Legacy GUI".

Unity Script Gizmo Example 2

1
  • is that Odin? 👀
    – Cool guy
    May 21 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.