- Home /
Inspector Titlebar for class derived from Object
Currently I have a class named Node. Node derives from ScriptableObject (which derives from Object).
In a custom editor (for a different script), I wish to loop through a list of Node instances, displaying the details of each under their own InspectorTitlebar.
So quite simply the code:
EditorGUILayout.InspectorTitlebar(true, nodeList.nodes[i]);
I would think would display a titlebar that has an icon assosciated with Node.cs and text that says 'Node'.
But no, the icon is a generic unity icon, and the text says "Mono Behaviour" (which is stupid not only because I can't seem to modify it, but because Node isn't even a Mono Behaviour).
So my question is, how can I set the icon for this, and how could I change the text?
Answer by samizzo · May 13, 2014 at 02:34 AM
For the icon, if you create an icon in Assets/Gizmos with the name "ClassName icon.png" (apparently tif also works) then it should show that icon when you call InspectorTitlebar. So for your class called Node the file would be "Node icon.png".
For the name, digging in to the InspectorTitlebar method with ILDasm it looks like it calls ObjectNames.GetInspectorTitle which will return "Scriptname (Script)" if the object is a script so the only way to override that is to change the name of your script (also I think the script name needs to match the file name even if it doesn't derive from MonoBehaviour).
I have had no luck getting any other UnityEngine.Object-derived type into InspectorTitlebar. I can't seem to new objects that are derived directly from UnityEngine.Object.
Your answer
Follow this Question
Related Questions
Inspector: custom property with custom type use default editor 3 Answers
CustomEditor : DrawDefaultInspector for Class 1 Answer
How do I get the default scene GUI for a CustomEditor for RectTransform? 1 Answer
Unity editor and inspector header 0 Answers
Expanding a custom property drawer of a list item forces further items in the list to disappear. 2 Answers