Hi,
I’m currently fooling around with some custom inspector stuff and since in the unity default inspector you can often see textfields with an icon inside the textfield I wondered how they did this?
Look for example at the first item in every monobehaviour inspector where they show the script name, there’s a little c# script icon right in front of the text.
Does somebody know how to achieve this?
Greetings
Hi! That particular field is an ObjectField, not a text field. Object fields (i.e. a serialized field that contains a reference to a UnityEngine.Object of some kind) will display the icon associated with the type in question. For custom scripts (e.g., MonoBehaviours or ScriptableObjects) this icon is the one specified on the script asset in your project view (up at the very top left of the Inspector when you have the script selected).
That said, if you are wanting to actually implement a text field with an icon or something on it, I strongly recommend you check out the PropertyDrawer class.