- Home /
Changing the Inspector Titlebar icon, and Text?
I've created a MonoBehaviour, and have attached it to a GameObject(mostly because I am unable to do this with just a custom Component class, opposed to the MonoBehavour class). Though if I were to create a Camera Object, I'd see that the 'Camera' Insepector TitleBar has no (Script) text next to the TypeName Text, and has its own Icon(which looks like a camera, where the MonoBehaviour component looks like a piece of paper).
Is this possible? If I'm going about it wrong, then how-so? I'd prefer to have just created a custom GameObject, though in my previous attempt I found problems rendering the DefaultGUIInspector(it looked nothing like the regular GameObjects GUI Inspector.. became annoying). Perhaps, I'm just a bit of a perfectionist, but I'm still interested in the possibilities here.
Answer by jonas-echterhoff · Nov 19, 2009 at 10:38 AM
(Script) is appended to any MonoBehaviour derived class, no way to change that. Even some built-in classes (like Terrain, which is implemented as a Mono script), have it.
To change the icon, simply add a custom texture to your project with such a path: Gizmos/NewBehaviourScript Icon.png
(Only .png and .tif are accepted file formats here.)
Works perfectly thx! But how do you changes the Icon in the inspector?
I'm having problem with this... Is the name "nameOfScript Icon" or "nameOfScript"? Is it Assets/Gizmos/ or the folder Gizmos can exist somewhere else?
Has to be in Assets/Gizmos file name is ClassName icon.(png/tif) That is Class Name (capitalized like your class) [space] icon.(png/tif)
Hmm... Doesn't work. I have a script named "Scene" and a file Assets/Gizmos/Scene icon.png and my scripts don't take the icon automatically. And why is this not documented anywhere?
This method does not work when the $$anonymous$$onoBehaviour is in a namespace. See here for an explanation of what one user has previously attempted.
Answer by skalev · Sep 06, 2013 at 06:26 AM
To change the icon in the inspector, you have to change the icon in unity for your actual script file that defines the assets. For instance I have a class called CodexCard, and assets are created using CreateInstance. So if you change the icon in the inspector while inspecting the ACTUAL script class file (not the asset!) it will show up.
took me a while to figure that out ;)
Answer by bszalapski · Jun 10, 2020 at 05:42 PM
Regarding the script's title, there is actually a way to do this. Above the class declaration, add the [AddComponentMenu("...")]
decorator, e.g:
[AddComponentMenu("Special Name")]
public class MyScript : MonoBehaviour
{ ... }
This is the name that will be used when you select "Add Component" and also the name displayed in the inspector for this component when attached to a GameObject.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
One of my scripts has no check-box next to it in Inspector 2 Answers
How to use intelisence in mono (in order to get all the contents of other script file) 1 Answer
How to import the object from server to unity 2 Answers
monobehaviour script accessing problem causes error 1 Answer